Sha256: 1779fe43397ba3ab5e52d94389766a33f21f23487da10423833c9840df7ae6f8

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

module Geokit
  module NetAdapter
    class NetHttp
      def self.do_get(url)
        uri = URI(url)
        req = Net::HTTP::Get.new(uri.request_uri)
        req.basic_auth(uri.user, uri.password) if uri.userinfo
        net_http_args = [uri.host, uri.port]
        if (proxy_uri_string = Geokit::Geocoders.proxy)
          proxy_uri = URI.parse(proxy_uri_string)
          net_http_args += [proxy_uri.host,
                            proxy_uri.port,
                            proxy_uri.user,
                            proxy_uri.password]
        end
        http = Net::HTTP.new(*net_http_args)
        if uri.scheme == "https"
          http.use_ssl = true
          http.verify_mode = Geokit::Geocoders.ssl_verify_mode
        end
        http.start { |h| h.request(req) }
      end

      def self.success?(response)
        response.is_a?(Net::HTTPSuccess)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geokit-1.10.0 lib/geokit/net_adapter/net_http.rb