Sha256: 11f823fd1b5786ab26e796d7b46e1c84d8e11df01d56c6db01f451858c4a9280
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
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(protocol, url = nil) # TODO: Remove once on 1.0.0 #initialize(config) config = protocol if url config = OpenStruct.new config.protocol = protocol config.url = url end uri = URI.parse("#{config.protocol}://#{config.url}") @http = Net::HTTP.new(uri.host, uri.port) @http.open_timeout = config.open_timeout || 5 @http.read_timeout = config.read_timeout || 5 @http.use_ssl = (config.protocol == 'https'.freeze) end def get(url) @http.request(Net::HTTP::Get.new(url)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
timezone-0.99.2 | lib/timezone/net_http_client.rb |
timezone-0.99.1 | lib/timezone/net_http_client.rb |
timezone-0.99.0 | lib/timezone/net_http_client.rb |