Class: Twingly::HTTP::Client
- Inherits:
-
Object
- Object
- Twingly::HTTP::Client
- Defined in:
- lib/twingly/http.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_RETRYABLE_EXCEPTIONS =
[ Faraday::ConnectionFailed, Faraday::SSLError, Zlib::BufError, Zlib::DataError, ].freeze
- TIMEOUT_EXCEPTIONS =
[ Faraday::TimeoutError, Net::OpenTimeout, ].freeze
- DEFAULT_HTTP_TIMEOUT =
20
- DEFAULT_HTTP_OPEN_TIMEOUT =
10
- DEFAULT_NUMBER_OF_RETRIES =
0
- DEFAULT_RETRY_INTERVAL =
1
- DEFAULT_MAX_URL_SIZE_BYTES =
Float::INFINITY
- DEFAULT_MAX_RESPONSE_BODY_SIZE_BYTES =
Float::INFINITY
- DEFAULT_FOLLOW_REDIRECTS_LIMIT =
3
Instance Attribute Summary collapse
-
#follow_redirects ⇒ Object
writeonly
Sets the attribute follow_redirects.
-
#follow_redirects_limit ⇒ Object
Returns the value of attribute follow_redirects_limit.
-
#http_open_timeout ⇒ Object
writeonly
Sets the attribute http_open_timeout.
-
#http_timeout ⇒ Object
writeonly
Sets the attribute http_timeout.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_response_body_size_bytes ⇒ Object
writeonly
Sets the attribute max_response_body_size_bytes.
-
#max_url_size_bytes ⇒ Object
writeonly
Sets the attribute max_url_size_bytes.
-
#number_of_retries ⇒ Object
writeonly
Sets the attribute number_of_retries.
-
#on_retry_callback ⇒ Object
writeonly
Sets the attribute on_retry_callback.
-
#request_id ⇒ Object
writeonly
Sets the attribute request_id.
-
#retry_interval ⇒ Object
writeonly
Sets the attribute retry_interval.
-
#retryable_exceptions ⇒ Object
Returns the value of attribute retryable_exceptions.
Instance Method Summary collapse
- #delete(url, params: {}, headers: {}) ⇒ Object
- #get(url, params: {}, headers: {}) ⇒ Object
-
#initialize(base_user_agent:, logger: default_logger, user_agent: nil, proxy: nil) ⇒ Client
constructor
A new instance of Client.
- #patch(url, body:, headers: {}) ⇒ Object
- #post(url, body:, headers: {}) ⇒ Object
- #put(url, body:, headers: {}) ⇒ Object
Constructor Details
#initialize(base_user_agent:, logger: default_logger, user_agent: nil, proxy: nil) ⇒ Client
Returns a new instance of Client.
53 54 55 56 57 58 59 60 |
# File 'lib/twingly/http.rb', line 53 def initialize(base_user_agent:, logger: default_logger, user_agent: nil, proxy: nil) @base_user_agent = base_user_agent @logger = logger @user_agent = user_agent @proxy = proxy initialize_defaults end |
Instance Attribute Details
#follow_redirects=(value) ⇒ Object (writeonly)
Sets the attribute follow_redirects
47 48 49 |
# File 'lib/twingly/http.rb', line 47 def follow_redirects=(value) @follow_redirects = value end |
#follow_redirects_limit ⇒ Object
Returns the value of attribute follow_redirects_limit.
49 50 51 |
# File 'lib/twingly/http.rb', line 49 def follow_redirects_limit @follow_redirects_limit end |
#http_open_timeout=(value) ⇒ Object (writeonly)
Sets the attribute http_open_timeout
40 41 42 |
# File 'lib/twingly/http.rb', line 40 def http_open_timeout=(value) @http_open_timeout = value end |
#http_timeout=(value) ⇒ Object (writeonly)
Sets the attribute http_timeout
39 40 41 |
# File 'lib/twingly/http.rb', line 39 def http_timeout=(value) @http_timeout = value end |
#logger ⇒ Object
Returns the value of attribute logger.
50 51 52 |
# File 'lib/twingly/http.rb', line 50 def logger @logger end |
#max_response_body_size_bytes=(value) ⇒ Object (writeonly)
Sets the attribute max_response_body_size_bytes
45 46 47 |
# File 'lib/twingly/http.rb', line 45 def max_response_body_size_bytes=(value) @max_response_body_size_bytes = value end |
#max_url_size_bytes=(value) ⇒ Object (writeonly)
Sets the attribute max_url_size_bytes
44 45 46 |
# File 'lib/twingly/http.rb', line 44 def max_url_size_bytes=(value) @max_url_size_bytes = value end |
#number_of_retries=(value) ⇒ Object (writeonly)
Sets the attribute number_of_retries
41 42 43 |
# File 'lib/twingly/http.rb', line 41 def number_of_retries=(value) @number_of_retries = value end |
#on_retry_callback=(value) ⇒ Object (writeonly)
Sets the attribute on_retry_callback
43 44 45 |
# File 'lib/twingly/http.rb', line 43 def on_retry_callback=(value) @on_retry_callback = value end |
#request_id=(value) ⇒ Object (writeonly)
Sets the attribute request_id
46 47 48 |
# File 'lib/twingly/http.rb', line 46 def request_id=(value) @request_id = value end |
#retry_interval=(value) ⇒ Object (writeonly)
Sets the attribute retry_interval
42 43 44 |
# File 'lib/twingly/http.rb', line 42 def retry_interval=(value) @retry_interval = value end |
#retryable_exceptions ⇒ Object
Returns the value of attribute retryable_exceptions.
51 52 53 |
# File 'lib/twingly/http.rb', line 51 def retryable_exceptions @retryable_exceptions end |
Instance Method Details
#delete(url, params: {}, headers: {}) ⇒ Object
78 79 80 |
# File 'lib/twingly/http.rb', line 78 def delete(url, params: {}, headers: {}) http_response_for(:delete, url: url, params: params, headers: headers) end |
#get(url, params: {}, headers: {}) ⇒ Object
62 63 64 |
# File 'lib/twingly/http.rb', line 62 def get(url, params: {}, headers: {}) http_response_for(:get, url: url, params: params, headers: headers) end |
#patch(url, body:, headers: {}) ⇒ Object
74 75 76 |
# File 'lib/twingly/http.rb', line 74 def patch(url, body:, headers: {}) http_response_for(:patch, url: url, body: body, headers: headers) end |
#post(url, body:, headers: {}) ⇒ Object
66 67 68 |
# File 'lib/twingly/http.rb', line 66 def post(url, body:, headers: {}) http_response_for(:post, url: url, body: body, headers: headers) end |
#put(url, body:, headers: {}) ⇒ Object
70 71 72 |
# File 'lib/twingly/http.rb', line 70 def put(url, body:, headers: {}) http_response_for(:put, url: url, body: body, headers: headers) end |