]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Fix redirection in httputil.get when location is only a partial/realtive url
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 19 Oct 2006 21:47:40 +0000 (21:47 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 19 Oct 2006 21:47:40 +0000 (21:47 +0000)
lib/rbot/httputil.rb

index bcb05d885b8bd10b4bfc40296364ce4876d2ce9a..e80a45aa388fa4a48e3244f280f1101c6b65c389 100644 (file)
@@ -143,6 +143,7 @@ class HttpUtil
     else
       uri = URI.parse(uri_or_str.to_s)
     end
     else
       uri = URI.parse(uri_or_str.to_s)
     end
+    debug "Getting #{uri}"
 
     proxy = get_proxy(uri)
     proxy.open_timeout = opentimeout
 
     proxy = get_proxy(uri)
     proxy.open_timeout = opentimeout
@@ -174,7 +175,7 @@ class HttpUtil
           debug "Redirecting #{uri} to #{resp['location']}"
           yield resp['location'] if block_given?
           if max_redir > 0
           debug "Redirecting #{uri} to #{resp['location']}"
           yield resp['location'] if block_given?
           if max_redir > 0
-            return get( URI.parse(resp['location']), readtimeout, opentimeout, max_redir-1, cache)
+            return get( URI.join(uri.to_s, resp['location']), readtimeout, opentimeout, max_redir-1, cache)
           else
             warning "Max redirection reached, not going to #{resp['location']}"
           end
           else
             warning "Max redirection reached, not going to #{resp['location']}"
           end