Method: Gem::Net::HTTP.get_response

Defined in:
lib/rubygems/vendor/net-http/lib/net/http.rb

.get_response(uri_or_host, path_or_headers = nil, port = nil, &block) ⇒ Object

:call-seq:

Gem::Net::HTTP.get_response(hostname, path, port = 80) -> http_response
Gem::Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response

Like Gem::Net::HTTP.get, but returns a Gem::Net::HTTPResponse object instead of the body string.



820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'lib/rubygems/vendor/net-http/lib/net/http.rb', line 820

def HTTP.get_response(uri_or_host, path_or_headers = nil, port = nil, &block)
  if path_or_headers && !path_or_headers.is_a?(Hash)
    host = uri_or_host
    path = path_or_headers
    new(host, port || HTTP.default_port).start {|http|
      return http.request_get(path, &block)
    }
  else
    uri = uri_or_host
    headers = path_or_headers
    start(uri.hostname, uri.port,
          :use_ssl => uri.scheme == 'https') {|http|
      return http.request_get(uri, headers, &block)
    }
  end
end