From a8e1e6acbdba3774712eaa8d6039817eb5dc55fa Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sun, 27 Jul 2008 19:13:25 -0400 Subject: [PATCH] tweaked the way base uri works and set https to not verify so we don't get warnings --- lib/web.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/web.rb b/lib/web.rb index ecffa58..01c578a 100644 --- a/lib/web.rb +++ b/lib/web.rb @@ -19,6 +19,8 @@ module Web module ClassMethods def base_uri(base_uri=nil) return @base_uri unless base_uri + # don't want this to ever end with / + base_uri = base_uri.ends_with?('/') ? base_uri.chop : base_uri @base_uri = ensure_http(base_uri) end @@ -31,6 +33,8 @@ module Web uri = URI.parse(base_uri) @http = Net::HTTP.new(uri.host, uri.port) @http.use_ssl = (uri.port == 443) + # so we can avoid ssl warnings + @http.verify_mode = OpenSSL::SSL::VERIFY_NONE end @http end @@ -70,8 +74,10 @@ module Web # body => string for raw post data # headers => hash of headers to send request with def send_request(method, path, options={}) + # we always want path that begins with / + path = path.starts_with?('/') ? path : "/#{path}" @format = format_from_path(path) unless @format - uri = URI.join(base_uri, path) + uri = URI.parse("#{base_uri}#{path}") uri.query = options[:query].to_query unless options[:query].blank? klass = Net::HTTP.const_get method.to_s.downcase.capitalize request = klass.new(uri.request_uri)