lib/trav3/get.rb in trav3-0.0.5 vs lib/trav3/get.rb in trav3-0.1.0
- old
+ new
@@ -3,11 +3,18 @@
require 'json'
require 'trav3/result'
module Trav3
module GET
- def self.call(url)
- response = Net::HTTP.get_response(URI(url))
+ def self.call(url, headers = {})
+ uri = URI(url)
+ req = Net::HTTP::Get.new(uri.request_uri)
+ headers.each_pair { |header, value|
+ req[header] = value
+ }
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = (uri.scheme == "https")
+ response = http.request(req)
if Net::HTTPOK == response.code_type
Success.new(response)
else
RequestError.new(response)