class WebkitRemote::Client::NetworkResource

Wraps information about the network operations for retrieving a resource.

Attributes

canceled[R]

@return [Boolean] true if the request fetch was canceled

client[R]

@return [WebkitRemote::Client] remote debugging client that reported this

document_url[R]

@return [String] the URL of the document that referenced this resource

error[R]

@return [String] error message, if the resource fetching failed

initiator[R]

@return [WebkitRemote::Client::NetworkRequestInitiator] cause for this

resource to be fetched from the network
last_event[R]

@return [WebkitRemote::Event] last event connected to this resource; can be

used to determine the resource's status
remote_id[R]

@return [String] request_id assigned by the remote WebKit debugger

request[R]

@return [WebkitRemote::Client::NetworkRequest] network request (most likely

HTTP) used to fetch this resource
response[R]

@return [WebkitRemote::Client::NetworkRequest] network response that

contains this resource
type[R]

@return [Symbol] the type of this resource; documented values are

:document, :font, :image, :other, :script, :stylesheet, :websocket and
:xhr

Public Class Methods

new(remote_id, client) click to toggle source

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

add_event(event) click to toggle source

@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
body() click to toggle source

@return [String] the contents of the resource

# File lib/webkit_remote/client/network_events.rb, line 279
def body
  @body ||= body!
end
body!() click to toggle source

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
set_canceled(new_canceled) click to toggle source

@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
set_document_url(new_document_url) click to toggle source

@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
set_error(new_error) click to toggle source

@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
set_initiator(new_initiator) click to toggle source

@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
set_request(new_request) click to toggle source

@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
set_response(new_response) click to toggle source

@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
set_type(new_type) click to toggle source

@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