Class: Appium::Core::Base::Http::Default
- Inherits:
-
Selenium::WebDriver::Remote::Http::Default
- Object
- Selenium::WebDriver::Remote::Http::Common
- Selenium::WebDriver::Remote::Http::Default
- Appium::Core::Base::Http::Default
- Defined in:
- lib/appium_lib_core/common/base/http_default.rb,
sig/lib/appium_lib_core/common/base/http_default.rbs
Constant Summary
Constants inherited from Selenium::WebDriver::Remote::Http::Default
Selenium::WebDriver::Remote::Http::Default::MAX_RETRIES
Constants inherited from Selenium::WebDriver::Remote::Http::Common
Selenium::WebDriver::Remote::Http::Common::CONTENT_TYPE, Selenium::WebDriver::Remote::Http::Common::DEFAULT_HEADERS, Selenium::WebDriver::Remote::Http::Common::MAX_REDIRECTS
Instance Attribute Summary collapse
-
#additional_headers ⇒ Object
readonly
Returns the value of attribute additional_headers.
Attributes inherited from Selenium::WebDriver::Remote::Http::Default
#open_timeout, #proxy, #read_timeout
Attributes inherited from Selenium::WebDriver::Remote::Http::Common
Instance Method Summary collapse
- #delete_additional_header(key) ⇒ Object
-
#initialize(open_timeout: nil, read_timeout: nil) ⇒ Default
constructor
override.
- #set_additional_header(key, value) ⇒ Object
-
#update_sending_request_to(scheme:, host:, port:, path:) ⇒ URI
Update
server_urlprovided when ruby_lib _core created a default http client. - #validate_url_param(scheme, host, port, path) ⇒ Boolean
Methods inherited from Selenium::WebDriver::Remote::Http::Default
#close, #http, #new_http_client, #new_request_for, #proxy, #request, #response_for, #start, #use_proxy?
Methods inherited from Selenium::WebDriver::Remote::Http::Common
#call, #close, #create_response, extra_headers, extra_headers=, #quit_errors, #request, #server_url, user_agent, user_agent=
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_headers ⇒ Object (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
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 self.server_url = URI.parse "#{scheme}://#{host}:#{port}#{path}" end |
#validate_url_param(scheme, host, port, path) ⇒ Boolean
78 79 80 81 82 83 84 |
# File 'lib/appium_lib_core/common/base/http_default.rb', line 78 def validate_url_param(scheme, host, port, path) return true unless [scheme, host, port, path].include?(nil) = "Given parameters are scheme: '#{scheme}', host: '#{host}', port: '#{port}', path: '#{path}'" ::Appium::Logger.debug() false end |