Class: WebkitRemote::Client::NetworkResource
- Inherits:
-
Object
- Object
- WebkitRemote::Client::NetworkResource
- Defined in:
- lib/webkit_remote/client/network_events.rb
Overview
Wraps information about the network operations for retrieving a resource.
Instance Attribute Summary collapse
-
#canceled ⇒ Boolean
readonly
True if the request fetch was canceled.
-
#client ⇒ WebkitRemote::Client
readonly
Remote debugging client that reported this.
-
#document_url ⇒ String
readonly
The URL of the document that referenced this resource.
-
#error ⇒ String
readonly
Error message, if the resource fetching failed.
-
#initiator ⇒ WebkitRemote::Client::NetworkRequestInitiator
readonly
Cause for this resource to be fetched from the network.
-
#last_event ⇒ WebkitRemote::Event
readonly
Last event connected to this resource; can be used to determine the resource’s status.
-
#remote_id ⇒ String
readonly
Request_id assigned by the remote WebKit debugger.
-
#request ⇒ WebkitRemote::Client::NetworkRequest
readonly
Network request (most likely HTTP) used to fetch this resource.
-
#response ⇒ WebkitRemote::Client::NetworkRequest
readonly
Network response that contains this resource.
-
#type ⇒ Symbol
readonly
The type of this resource; documented values are :document, :font, :image, :other, :script, :stylesheet, :websocket and :xhr.
Instance Method Summary collapse
- #add_event(event) ⇒ Object
-
#body ⇒ String
The contents of the resource.
-
#body! ⇒ String
Re-fetches the resource from the Webkit remote debugging server.
-
#initialize(remote_id, client) ⇒ NetworkResource
constructor
Creates an empty network operation wrapper.
- #set_canceled(new_canceled) ⇒ Object
- #set_document_url(new_document_url) ⇒ Object
- #set_error(new_error) ⇒ Object
- #set_initiator(new_initiator) ⇒ Object
- #set_request(new_request) ⇒ Object
- #set_response(new_response) ⇒ Object
- #set_type(new_type) ⇒ Object
Constructor Details
#initialize(remote_id, client) ⇒ NetworkResource
Creates an empty network operation wrapper.
265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/webkit_remote/client/network_events.rb', line 265 def initialize(remote_id, client) @remote_id = remote_id @client = client @request = nil @response = nil @type = nil @document_url = nil @initiator = nil @canceled = false @last_event = nil @body = false end |
Instance Attribute Details
#canceled ⇒ Boolean (readonly)
Returns true if the request fetch was canceled.
243 244 245 |
# File 'lib/webkit_remote/client/network_events.rb', line 243 def canceled @canceled end |
#client ⇒ WebkitRemote::Client (readonly)
Returns remote debugging client that reported this.
253 254 255 |
# File 'lib/webkit_remote/client/network_events.rb', line 253 def client @client end |
#document_url ⇒ String (readonly)
Returns the URL of the document that referenced this resource.
236 237 238 |
# File 'lib/webkit_remote/client/network_events.rb', line 236 def document_url @document_url end |
#error ⇒ String (readonly)
Returns error message, if the resource fetching failed.
246 247 248 |
# File 'lib/webkit_remote/client/network_events.rb', line 246 def error @error end |
#initiator ⇒ WebkitRemote::Client::NetworkRequestInitiator (readonly)
Returns cause for this resource to be fetched from the network.
240 241 242 |
# File 'lib/webkit_remote/client/network_events.rb', line 240 def initiator @initiator end |
#last_event ⇒ WebkitRemote::Event (readonly)
Returns last event connected to this resource; can be used to determine the resource’s status.
250 251 252 |
# File 'lib/webkit_remote/client/network_events.rb', line 250 def last_event @last_event end |
#remote_id ⇒ String (readonly)
Returns request_id assigned by the remote WebKit debugger.
256 257 258 |
# File 'lib/webkit_remote/client/network_events.rb', line 256 def remote_id @remote_id end |
#request ⇒ WebkitRemote::Client::NetworkRequest (readonly)
Returns network request (most likely HTTP) used to fetch this resource.
224 225 226 |
# File 'lib/webkit_remote/client/network_events.rb', line 224 def request @request end |
#response ⇒ WebkitRemote::Client::NetworkRequest (readonly)
Returns network response that contains this resource.
228 229 230 |
# File 'lib/webkit_remote/client/network_events.rb', line 228 def response @response end |
#type ⇒ Symbol (readonly)
Returns the type of this resource; documented values are :document, :font, :image, :other, :script, :stylesheet, :websocket and :xhr.
233 234 235 |
# File 'lib/webkit_remote/client/network_events.rb', line 233 def type @type end |
Instance Method Details
#add_event(event) ⇒ Object
338 339 340 341 |
# File 'lib/webkit_remote/client/network_events.rb', line 338 def add_event(event) @last_event = event # TODO(pwnall): consider keeping track of all events end |
#body ⇒ String
Returns the contents of the resource.
279 280 281 |
# File 'lib/webkit_remote/client/network_events.rb', line 279 def body @body ||= body! end |
#body! ⇒ String
Re-fetches the resource from the Webkit remote debugging server.
286 287 288 289 290 291 292 293 |
# File 'lib/webkit_remote/client/network_events.rb', line 286 def body! result = @client.rpc.call 'Network.getResponseBody', requestId: @remote_id if result['base64Encoded'] @body = Base64.decode64 result['body'] else @body = result['body'] end end |
#set_canceled(new_canceled) ⇒ Object
296 297 298 |
# File 'lib/webkit_remote/client/network_events.rb', line 296 def set_canceled(new_canceled) @canceled ||= new_canceled end |
#set_document_url(new_document_url) ⇒ Object
301 302 303 304 |
# File 'lib/webkit_remote/client/network_events.rb', line 301 def set_document_url(new_document_url) return if new_document_url == nil @document_url = new_document_url end |
#set_error(new_error) ⇒ Object
307 308 309 310 |
# File 'lib/webkit_remote/client/network_events.rb', line 307 def set_error(new_error) return if new_error == nil @error = new_error end |
#set_initiator(new_initiator) ⇒ Object
313 314 315 316 |
# File 'lib/webkit_remote/client/network_events.rb', line 313 def set_initiator(new_initiator) return if new_initiator == nil @initiator = new_initiator end |
#set_request(new_request) ⇒ Object
319 320 321 322 323 |
# File 'lib/webkit_remote/client/network_events.rb', line 319 def set_request(new_request) return if new_request == nil # TODO(pwnall): consider handling multiple requests @request = new_request end |
#set_response(new_response) ⇒ Object
326 327 328 329 |
# File 'lib/webkit_remote/client/network_events.rb', line 326 def set_response(new_response) return if new_response == nil @response = new_response end |
#set_type(new_type) ⇒ Object
332 333 334 335 |
# File 'lib/webkit_remote/client/network_events.rb', line 332 def set_type(new_type) return if new_type == nil @type = new_type end |