module WebkitRemote::Client::Network
API for the Network
domain.
Attributes
@return [Boolean] true if the browser's network cache is disabled, so every
resource load generates an HTTP request
@return [Hash<String, String>]
@return [Boolean] true if the debugger generates Network.* events
@return [Array<WebkitRemote::Client::NetworkResource>] the resources
fetched during the debugging session
This is only populated when Network
events are received.
@return [String] replaces the brower's built-in User-Agent string
Public Instance Methods
Checks if the debugger can clear the browser's cache.
@return [Boolean] true if WebkitRemote::Client::Network#clear_network_cache
can be succesfully called
# File lib/webkit_remote/client/network.rb, line 81 def can_clear_network_cache? response = @rpc.call 'Network.canClearBrowserCache' !!response['result'] end
Removes the cached network request information.
@return [WebkitRemote::Client] self
# File lib/webkit_remote/client/network.rb, line 134 def clear_network @network_resource_hash.clear @network_resources.clear self end
Removes all the cached data in the debugged browser.
@return [WebkitRemote::Client] self
# File lib/webkit_remote/client/network.rb, line 89 def clear_network_cache @rpc.call 'Network.clearBrowserCache' self end
Enables or disables the use of the network cache.
@param [Boolean] new_disable_cache if true, the browser will not use its
network cache, and will always generate HTTP requests
# File lib/webkit_remote/client/network.rb, line 24 def disable_cache=(new_disable_cache) new_disable_cache = !!new_disable_cache if new_disable_cache != disable_cache @rpc.call 'Network.setCacheDisabled', cacheDisabled: new_disable_cache @disable_cache = new_disable_cache end new_disable_cache end
Sets extra headers to be sent with every HTTP request.
@param [Hash<String, String>] new_extra_headers HTTP headers to be added to
every HTTP request sent by the browser
# File lib/webkit_remote/client/network.rb, line 49 def http_headers=(new_http_headers) new_http_headers = Hash[new_http_headers.map { |k, v| [k.to_s, v.to_s] }].freeze if new_http_headers != http_headers @rpc.call 'Network.setExtraHTTPHeaders', headers: new_http_headers @http_headers = new_http_headers end new_http_headers end
Enables or disables the generation of events in the Network
domain.
@param [Boolean] new_network_events if true, the browser debugger will
generate Network.* events
# File lib/webkit_remote/client/network.rb, line 11 def network_events=(new_network_events) new_network_events = !!new_network_events if new_network_events != network_events @rpc.call(new_network_events ? 'Network.enable' : 'Network.disable') @network_events = new_network_events end new_network_events end
Looks up network resources by IDs assigned by the WebKit remote debugger.
@private Use the resource property of Network
events instead of calling
this directly.
@param [String] remote_id the WebKit-assigned request_id @return [WebkitRemote::Client::NetworkResource] the cached information
about the resource with the given ID
# 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
Sets the User-Agent header that the browser will use to identify itself.
@param [String] new_user_agent will be used instead of the browser's
hard-coded User-Agent header
# File lib/webkit_remote/client/network.rb, line 37 def user_agent=(new_user_agent) if new_user_agent != user_agent @rpc.call 'Network.setUserAgentOverride', userAgent: new_user_agent @user_agent = new_user_agent end new_user_agent end