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



38
39
40
41
42
43
# File 'lib/appium_lib_core/common/base/http_default.rb', line 38

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

#delete_additional_header(key) ⇒ Object



50
51
52
53
54
# File 'lib/appium_lib_core/common/base/http_default.rb', line 50

def delete_additional_header(key)
  @additional_headers.delete key
  ::Selenium::WebDriver::Remote::Http::Common.extra_headers = @additional_headers
  @common_headers.delete key if defined? @common_headers
end

#set_additional_header(key, value) ⇒ Object



45
46
47
48
# File 'lib/appium_lib_core/common/base/http_default.rb', line 45

def set_additional_header(key, value)
  @additional_headers[key] = value
  ::Selenium::WebDriver::Remote::Http::Common.extra_headers = @additional_headers
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



65
66
67
68
69
70
71
72
73
74
# File 'lib/appium_lib_core/common/base/http_default.rb', line 65

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