Sha256: c8fc0f1a254ffa9c3efd73721a19e7282d87210ed3cdc45901b1baa874702b78

Contents?: true

Size: 718 Bytes

Versions: 14

Compression:

Stored size: 718 Bytes

Contents

require 'uri'
require 'net/http'

module Timezone
  # 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 but be aware that the 
  # Google timezone API uses https protocol.
  #
  # @example
  #     Timezone::Configure.begin do |c|
  #       c.http_client = Timezone::NetHTTPClient
  #     end
  class NetHTTPClient
    def initialize(protocol, host)
      uri = URI.parse("#{protocol}://#{host}")
      @http = Net::HTTP.new(uri.host, uri.port)
      @http.use_ssl = (protocol == 'https')
    end

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
timezone-0.6.0 lib/timezone/net_http_client.rb
timezone-0.5.0 lib/timezone/net_http_client.rb
timezone-0.4.3 lib/timezone/net_http_client.rb
timezone-0.4.2 lib/timezone/net_http_client.rb
timezone-0.4.1 lib/timezone/net_http_client.rb
timezone-0.4.0 lib/timezone/net_http_client.rb
timezone-0.3.11 lib/timezone/net_http_client.rb
timezone-0.3.10 lib/timezone/net_http_client.rb
timezone-0.3.9 lib/timezone/net_http_client.rb
timezone-0.3.8 lib/timezone/net_http_client.rb
timezone-0.3.7 lib/timezone/net_http_client.rb
timezone-0.3.6 lib/timezone/net_http_client.rb
timezone-0.3.5 lib/timezone/net_http_client.rb
timezone-0.3.4 lib/timezone/net_http_client.rb