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



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

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.



32
33
34
# File 'lib/appium_lib_core/common/base/http_default.rb', line 32

def additional_headers
  @additional_headers
end

Instance Method Details

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



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

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



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

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}" unless path.start_with?('/')
  path = "#{path}/" unless path.end_with?('/')

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