Class: WebkitRemote::Event::NetworkResponse

Inherits:
WebkitRemote::Event show all
Defined in:
lib/webkit_remote/client/network_events.rb

Overview

Emitted right after receiving a response to a network request.

Instance Attribute Summary collapse

Attributes inherited from WebkitRemote::Event

#domain, #name, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WebkitRemote::Event

can_receive?, class_for, for, #matches?, register, register_class

Constructor Details

#initialize(rpc_event, client) ⇒ NetworkResponse

Returns a new instance of NetworkResponse.



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/webkit_remote/client/network_events.rb', line 199

def initialize(rpc_event, client)
  super
  @loader_id = raw_data['loaderId']
  if raw_data['response']
    @response = WebkitRemote::Client::NetworkResponse.new(
        raw_data['response'])
  end
  @type = (raw_data['type'] || 'other').downcase.to_sym
  @timestamp = raw_data['timestamp']

  @resource = client.network_resource raw_data['requestId']
  @resource.set_response @response
  @resource.set_type @type
  @resource.add_event self
end

Instance Attribute Details

#loader_idString (readonly)

Returns used to correlate events.

Returns:

  • (String)

    used to correlate events



196
197
198
# File 'lib/webkit_remote/client/network_events.rb', line 196

def loader_id
  @loader_id
end

#resourceWebkitRemote::Client::NetworkResource (readonly)

Returns information about the resource fetched by this network operation.

Returns:



181
182
183
# File 'lib/webkit_remote/client/network_events.rb', line 181

def resource
  @resource
end

#responseWebkitRemote::Client::NetworkResponse (readonly)

Returns information about the HTTP response behind this event.

Returns:



185
186
187
# File 'lib/webkit_remote/client/network_events.rb', line 185

def response
  @response
end

#timestampNumber (readonly)

Returns the event timestamp.

Returns:

  • (Number)

    the event timestamp



193
194
195
# File 'lib/webkit_remote/client/network_events.rb', line 193

def timestamp
  @timestamp
end

#typeSymbol (readonly)

Returns the type of resource returned by this response; documented values are :document, :font, :image, :other, :script, :stylesheet, :websocket and :xhr.

Returns:

  • (Symbol)

    the type of resource returned by this response; documented values are :document, :font, :image, :other, :script, :stylesheet, :websocket and :xhr



190
191
192
# File 'lib/webkit_remote/client/network_events.rb', line 190

def type
  @type
end

Class Method Details

.can_reach?(client) ⇒ Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/webkit_remote/client/network_events.rb', line 216

def self.can_reach?(client)
  client.network_events
end