class WebkitRemote::Client::NetworkResource
Wraps information about the network operations for retrieving a resource.
Attributes
@return [Boolean] true if the request fetch was canceled
@return [WebkitRemote::Client] remote debugging client that reported this
@return [String] the URL of the document that referenced this resource
@return [String] error message, if the resource fetching failed
@return [WebkitRemote::Client::NetworkRequestInitiator] cause for this
resource to be fetched from the network
@return [WebkitRemote::Event] last event connected to this resource; can be
used to determine the resource's status
@return [String] request_id assigned by the remote WebKit debugger
@return [WebkitRemote::Client::NetworkRequest] network request (most likely
HTTP) used to fetch this resource
@return [WebkitRemote::Client::NetworkRequest] network response that
contains this resource
@return [Symbol] the type of this resource; documented values are
:document, :font, :image, :other, :script, :stylesheet, :websocket and :xhr
Public Class Methods
Creates an empty network operation wrapper.
@private Use WebkitRemote::Client::Network#network_op instead of calling
this directly.
@param [String] remote_id
the request_id used by the remote debugging
server to identify this network operation
@param [WebkitRemote::Client]
# 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
Public Instance Methods
@private Rely on the event processing code to set this property.
# 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
@return [String] the contents of the resource
# File lib/webkit_remote/client/network_events.rb, line 279 def body @body ||= body! end
Re-fetches the resource from the Webkit remote debugging server.
@return [String] the contents of the resource
# 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
@private Rely on the event processing code to set this property.
# File lib/webkit_remote/client/network_events.rb, line 296 def set_canceled(new_canceled) @canceled ||= new_canceled end
@private Rely on the event processing code to set this property.
# 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
@private Rely on the event processing code to set this property.
# File lib/webkit_remote/client/network_events.rb, line 307 def set_error(new_error) return if new_error == nil @error = new_error end
@private Rely on the event processing code to set this property.
# File lib/webkit_remote/client/network_events.rb, line 313 def set_initiator(new_initiator) return if new_initiator == nil @initiator = new_initiator end
@private Rely on the event processing code to set this property.
# 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
@private Rely on the event processing code to set this property.
# File lib/webkit_remote/client/network_events.rb, line 326 def set_response(new_response) return if new_response == nil @response = new_response end
@private Rely on the event processing code to set this property.
# File lib/webkit_remote/client/network_events.rb, line 332 def set_type(new_type) return if new_type == nil @type = new_type end