Class: Selenium::WebDriver::Remote::Http::Common
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::Http::Common
- Defined in:
- lib/selenium/webdriver/remote/http/common.rb
Constant Summary collapse
- MAX_REDIRECTS =
same as chromium/gecko
20
- CONTENT_TYPE =
'application/json'.freeze
- DEFAULT_HEADERS =
{'Accept' => CONTENT_TYPE}.freeze
Instance Attribute Summary collapse
-
#server_url ⇒ Object
writeonly
Sets the attribute server_url.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #call(verb, url, command_hash) ⇒ Object
- #close ⇒ Object
-
#initialize ⇒ Common
constructor
A new instance of Common.
- #quit_errors ⇒ Object
Constructor Details
#initialize ⇒ Common
Returns a new instance of Common.
32 33 34 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 32 def initialize @timeout = nil end |
Instance Attribute Details
#server_url=(value) ⇒ Object
Sets the attribute server_url
30 31 32 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 30 def server_url=(value) @server_url = value end |
#timeout ⇒ Object
Returns the value of attribute timeout.
29 30 31 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 29 def timeout @timeout end |
Instance Method Details
#call(verb, url, command_hash) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 44 def call(verb, url, command_hash) url = server_url.merge(url) unless url.is_a?(URI) headers = DEFAULT_HEADERS.dup headers['Cache-Control'] = 'no-cache' if verb == :get if command_hash payload = JSON.generate(command_hash) headers['Content-Type'] = "#{CONTENT_TYPE}; charset=utf-8" headers['Content-Length'] = payload.bytesize.to_s if [:post, :put].include?(verb) WebDriver.logger.info(" >>> #{url} | #{payload}") WebDriver.logger.debug(" > #{headers.inspect}") elsif verb == :post payload = '{}' headers['Content-Length'] = '2' end request verb, url, headers, payload end |
#close ⇒ Object
40 41 42 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 40 def close # hook for subclasses - will be called on Driver#quit end |
#quit_errors ⇒ Object
36 37 38 |
# File 'lib/selenium/webdriver/remote/http/common.rb', line 36 def quit_errors [IOError] end |