Class: Selenium::WebDriver::Remote::Http::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/remote/http/common.rb

Direct Known Subclasses

Curb, Default

Constant Summary collapse

MAX_REDIRECTS =

same as chromium/gecko

20
CONTENT_TYPE =
"application/json"
DEFAULT_HEADERS =
{ "Accept" => CONTENT_TYPE, "Content-Length" => "0" }

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Common

Returns a new instance of Common.



14
15
16
# File 'lib/selenium/webdriver/remote/http/common.rb', line 14

def initialize(url)
  @server_url = url
end

Class Attribute Details

.timeoutObject

Returns the value of attribute timeout.



11
12
13
# File 'lib/selenium/webdriver/remote/http/common.rb', line 11

def timeout
  @timeout
end

Instance Method Details

#call(verb, url, command_hash) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/selenium/webdriver/remote/http/common.rb', line 18

def call(verb, url, command_hash)
  url      = @server_url.merge(url) unless url.kind_of?(URI)
  headers  = DEFAULT_HEADERS.dup

  if command_hash
    payload                   = command_hash.to_json
    headers["Content-Type"]   = "#{CONTENT_TYPE}; charset=utf-8"
    headers["Content-Length"] = payload.bytesize.to_s if [:post, :put].include?(verb)

    if $DEBUG
      puts "   >>> #{payload}"
      puts "     > #{headers.inspect}"
    end
  end

  request verb, url, headers, payload
end