Class: FetchUtil::HttpRedirectClient

Inherits:
Object
  • Object
show all
Defined in:
lib/fetch_util/regulatory/http_client.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

REDIRECT_LIMIT =
5
TRANSIENT_ERRORS =
[EOFError, IOError, SocketError, SystemCallError, Timeout::Error].freeze

Instance Method Summary collapse

Constructor Details

#initialize(timeout:, headers: {}) ⇒ HttpRedirectClient

Returns a new instance of HttpRedirectClient.



12
13
14
15
# File 'lib/fetch_util/regulatory/http_client.rb', line 12

def initialize(timeout:, headers: {})
  @timeout = timeout.to_f
  @headers = headers.reject { |_key, value| value.to_s.empty? }
end

Instance Method Details

#get(url, limit: REDIRECT_LIMIT) ⇒ Object



17
18
19
20
21
22
# File 'lib/fetch_util/regulatory/http_client.rb', line 17

def get(url, limit: REDIRECT_LIMIT)
  @connections = {}
  fetch(parse_http_uri(url), limit, [])
ensure
  close_connections
end