Sha256: 77d29c97def6dda551800d51b7fa813f9732ce5deaa1d02d735b77798988efcb

Contents?: true

Size: 824 Bytes

Versions: 33

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

require 'uri'
require 'net/http'

module Timezone
  # @!visibility private
  # A basic HTTP Client that handles requests to Geonames and Google.
  #
  # You can create your own version of this class if you want to use
  # a proxy or a different http library such as faraday.
  #
  # @example
  #     Timezone::Lookup.config(:google) do |c|
  #       c.api_key = 'foo'
  #       c.request_handler = Timezone::NetHTTPClient
  #     end
  #
  class NetHTTPClient
    def initialize(config)
      @http = Net::HTTP.new(config.uri.host, config.uri.port)
      @http.open_timeout = config.open_timeout || 5
      @http.read_timeout = config.read_timeout || 5
      @http.use_ssl = (config.protocol == 'https')
    end

    def get(url)
      @http.request(Net::HTTP::Get.new(url))
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
timezone-1.3.28 lib/timezone/net_http_client.rb
timezone-1.3.27 lib/timezone/net_http_client.rb
timezone-1.3.26 lib/timezone/net_http_client.rb
timezone-1.3.25 lib/timezone/net_http_client.rb
timezone-1.3.24 lib/timezone/net_http_client.rb
timezone-1.3.23 lib/timezone/net_http_client.rb
timezone-1.3.22 lib/timezone/net_http_client.rb
timezone-1.3.21 lib/timezone/net_http_client.rb
timezone-1.3.20 lib/timezone/net_http_client.rb
timezone-1.3.19 lib/timezone/net_http_client.rb
timezone-1.3.18 lib/timezone/net_http_client.rb
timezone-1.3.17 lib/timezone/net_http_client.rb
timezone-1.3.16 lib/timezone/net_http_client.rb
timezone-1.3.15 lib/timezone/net_http_client.rb
timezone-1.3.14 lib/timezone/net_http_client.rb
timezone-1.3.13 lib/timezone/net_http_client.rb
timezone-1.3.12 lib/timezone/net_http_client.rb
timezone-1.3.11 lib/timezone/net_http_client.rb
timezone-1.3.10 lib/timezone/net_http_client.rb
timezone-1.3.9 lib/timezone/net_http_client.rb