Class: Puppeteer::NetworkManager
- Inherits:
-
Object
- Object
- Puppeteer::NetworkManager
show all
- Includes:
- EventCallbackable
- Defined in:
- lib/puppeteer/network_manager.rb
Defined Under Namespace
Classes: Credentials
Instance Method Summary
collapse
#add_event_listener, #emit_event, #on_event, #remove_event_listener
Constructor Details
#initialize(client, ignore_https_errors, frame_manager) ⇒ NetworkManager
Returns a new instance of NetworkManager.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/puppeteer/network_manager.rb', line 17
def initialize(client, ignore_https_errors, frame_manager)
@client = client
@ignore_https_errors = ignore_https_errors
@frame_manager = frame_manager
@request_id_to_request = {}
@request_id_to_request_with_be_sent_event
@extra_http_headers = {}
@offline = false
@user_request_interception_enabled = false
@protocol_request_interception_enabled = false
@user_cache_disabled = false
end
|
Instance Method Details
#authenticate(username:, password:) ⇒ Object
50
51
52
53
|
# File 'lib/puppeteer/network_manager.rb', line 50
def authenticate(username:, password:)
@credentials = Credentials.new(username: username, password: password)
update_protocol_request_interception
end
|
#cache_enabled=(enabled) ⇒ Object
91
92
93
94
|
# File 'lib/puppeteer/network_manager.rb', line 91
def cache_enabled=(enabled)
@user_cache_disabled = !enabled
update_protocol_cache_disabled
end
|
69
70
71
|
# File 'lib/puppeteer/network_manager.rb', line 69
def
@extra_http_headers.dup
end
|
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/puppeteer/network_manager.rb', line 56
def ()
= {}
.each do |key, value|
unless value.is_a?(String)
raise ArgumentError.new("Expected value of header \"#{key}\" to be String, but \"#{value}\" is found.")
end
[key.downcase] = value
end
@extra_http_headers =
@client.send_message('Network.setExtraHTTPHeaders', headers: )
end
|
#init ⇒ Object
41
42
43
44
45
46
|
# File 'lib/puppeteer/network_manager.rb', line 41
def init
@client.send_message('Network.enable')
if @ignore_https_errors
@client.send_message('Security.setIgnoreCertificateErrors', ignore: true)
end
end
|
#offline_mode=(value) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/puppeteer/network_manager.rb', line 74
def offline_mode=(value)
return if @offline == value
@offline = value
@client.send_message('Network.emulateNetworkConditions',
offline: @offline,
latency: 0,
downloadThroughput: -1,
uploadThroughput: -1,
)
end
|
#request_interception=(enabled) ⇒ Object
96
97
98
99
|
# File 'lib/puppeteer/network_manager.rb', line 96
def request_interception=(enabled)
@user_request_interception_enabled = enabled
update_protocol_request_interception
end
|
#user_agent=(user_agent) ⇒ Object
87
88
89
|
# File 'lib/puppeteer/network_manager.rb', line 87
def user_agent=(user_agent)
@client.send_message('Network.setUserAgentOverride', userAgent: user_agent)
end
|