Class: Appium::Core::Base::Http::Default

Inherits:
Selenium::WebDriver::Remote::Http::Default
  • Object
show all
Defined in:
lib/appium_lib_core/common/base/http_default.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_timeout: nil, read_timeout: nil) ⇒ Default

override



33
34
35
36
37
38
# File 'lib/appium_lib_core/common/base/http_default.rb', line 33

def initialize(open_timeout: nil, read_timeout: nil)
  @open_timeout = open_timeout
  @read_timeout = read_timeout
  @additional_headers = {}
  super
end

Instance Attribute Details

#additional_headersObject (readonly)

Returns the value of attribute additional_headers.



30
31
32
# File 'lib/appium_lib_core/common/base/http_default.rb', line 30

def additional_headers
  @additional_headers
end

Instance Method Details

#request(verb, url, headers, payload, redirects = 0) ⇒ Object



60
61
62
63
64
65
# File 'lib/appium_lib_core/common/base/http_default.rb', line 60

def request(verb, url, headers, payload, redirects = 0)
  headers['User-Agent'] = "appium/ruby_lib_core/#{VERSION} (#{headers['User-Agent']})"
  headers = headers.merge @additional_headers unless @additional_headers.empty?

  super(verb, url, headers, payload, redirects)
end

#update_sending_request_to(scheme:, host:, port:, path:) ⇒ URI

Update server_url provided when ruby_lib _core created a default http client. Set @http as nil to re-create http client for the server_url

Parameters:

  • scheme (string)

    A scheme to update server_url to

  • host (string)

    A host to update server_url to

  • port (string|integer)

    A port number to update server_url to

  • path (string)

    A path to update server_url to

Returns:

  • (URI)

    An instance of URI updated to. Returns default server_url if some of arguments are nil



49
50
51
52
53
54
55
56
57
58
# File 'lib/appium_lib_core/common/base/http_default.rb', line 49

def update_sending_request_to(scheme:, host:, port:, path:)
  return @server_url unless validate_url_param(scheme, host, port, path)

  # Add / if 'path' does not have it
  path = path.start_with?('/') ? path : "/#{path}"
  path = path.end_with?('/') ? path : "#{path}/"

  @http = nil
  @server_url = URI.parse "#{scheme}://#{host}:#{port}#{path}"
end