Method: ExtraSpace::Crawler#connection

Defined in:
lib/extraspace/crawler.rb

#connectionHTTP::Client

Returns:

  • (HTTP::Client)


23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/extraspace/crawler.rb', line 23

def connection
  @connection ||= begin
    config = ExtraSpace.config

    connection = HTTP.use(:auto_deflate).use(:auto_inflate).persistent(HOST)
    connection = connection.headers('User-Agent' => config.user_agent) if config.user_agent
    connection = connection.timeout(config.timeout) if config.timeout
    connection = connection.via(*config.via) if config.proxy?

    connection
  end
end