Module: WebkitRemote::Client::Network

Included in:
WebkitRemote::Client
Defined in:
lib/webkit_remote/client/network.rb

Overview

API for the Network domain.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#disable_cacheBoolean

Returns true if the browser’s network cache is disabled, so every resource load generates an HTTP request.

Returns:

  • (Boolean)

    true if the browser’s network cache is disabled, so every resource load generates an HTTP request



105
106
107
# File 'lib/webkit_remote/client/network.rb', line 105

def disable_cache
  @disable_cache
end

#http_headersHash<String, String>

Returns:

  • (Hash<String, String>)


111
112
113
# File 'lib/webkit_remote/client/network.rb', line 111

def http_headers
  @http_headers
end

#network_eventsBoolean

Returns true if the debugger generates Network.* events.

Returns:

  • (Boolean)

    true if the debugger generates Network.* events



95
96
97
# File 'lib/webkit_remote/client/network.rb', line 95

def network_events
  @network_events
end

#network_resourcesArray<WebkitRemote::Client::NetworkResource> (readonly)

This is only populated when Network events are received.

Returns:



101
102
103
# File 'lib/webkit_remote/client/network.rb', line 101

def network_resources
  @network_resources
end

#user_agentString

Returns replaces the brower’s built-in User-Agent string.

Returns:

  • (String)

    replaces the brower’s built-in User-Agent string



108
109
110
# File 'lib/webkit_remote/client/network.rb', line 108

def user_agent
  @user_agent
end

Instance Method Details

#can_clear_cookies?Boolean

Checks if the debugger can clear the browser’s cookies.

Returns:

  • (Boolean)

    true if WebkitRemote::Client::Network#clear_cookies can be succesfully called



64
65
66
67
# File 'lib/webkit_remote/client/network.rb', line 64

def can_clear_cookies?
  response = @rpc.call 'Network.canClearBrowserCookies'
  !!response['result']
end

#can_clear_network_cache?Boolean

Checks if the debugger can clear the browser’s cache.

Returns:

  • (Boolean)

    true if WebkitRemote::Client::Network#clear_network_cache can be succesfully called



81
82
83
84
# File 'lib/webkit_remote/client/network.rb', line 81

def can_clear_network_cache?
  response = @rpc.call 'Network.canClearBrowserCache'
  !!response['result']
end

#clear_cookiesWebkitRemote::Client

Removes all the cookies in the debugged browser.

Returns:



72
73
74
75
# File 'lib/webkit_remote/client/network.rb', line 72

def clear_cookies
  @rpc.call 'Network.clearBrowserCookies'
  self
end

#clear_networkWebkitRemote::Client

Removes the cached network request information.

Returns:



134
135
136
137
138
# File 'lib/webkit_remote/client/network.rb', line 134

def clear_network
  @network_resource_hash.clear
  @network_resources.clear
  self
end

#clear_network_cacheWebkitRemote::Client

Removes all the cached data in the debugged browser.

Returns:



89
90
91
92
# File 'lib/webkit_remote/client/network.rb', line 89

def clear_network_cache
  @rpc.call 'Network.clearBrowserCache'
  self
end

#initialize_networkObject



141
142
143
144
145
146
147
# File 'lib/webkit_remote/client/network.rb', line 141

def initialize_network
  @disable_cache = false
  @network_events = false
  @network_resources = []
  @network_resource_hash = {}
  @user_agent = nil
end

#network_resource(remote_id) ⇒ WebkitRemote::Client::NetworkResource

Looks up network resources by IDs assigned by the WebKit remote debugger.

Parameters:

  • remote_id (String)

    the WebKit-assigned request_id

Returns:



121
122
123
124
125
126
127
128
129
# File 'lib/webkit_remote/client/network.rb', line 121

def network_resource(remote_id)
  if @network_resource_hash[remote_id]
    return @network_resource_hash[remote_id]
  end
  resource = WebkitRemote::Client::NetworkResource.new remote_id, self

  @network_resources << resource
  @network_resource_hash[remote_id] = resource
end