Method: Down::Http#initialize

Defined in:
lib/down/http.rb

#initialize(options = {}, &block) ⇒ Http

Initializes the backend with common defaults.



15
16
17
18
19
20
21
22
23
24
# File 'lib/down/http.rb', line 15

def initialize(options = {}, &block)
  @method = options.delete(:method) || :get
  @client = HTTP
    .headers("User-Agent" => "Down/#{Down::VERSION}")
    .follow(max_hops: 2)
    .timeout(connect: 30, write: 30, read: 30)

  @client = HTTP::Client.new(@client.default_options.merge(options)) if options.any?
  @client = block.call(@client) if block
end