]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
HttpUtil: preserve authorization across redirects
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 8 Sep 2007 17:14:54 +0000 (17:14 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 8 Sep 2007 17:14:54 +0000 (17:14 +0000)
lib/rbot/core/utils/httputil.rb

index 2b71452786193050fa6dce36ee7e8ab41def089a..11f3cb41a2d9abdfd8e9c824ea007a3c34304570 100644 (file)
@@ -473,10 +473,14 @@ class HttpUtil
 
     headers = @headers.dup.merge(opts[:headers] || {})
     headers['Range'] = opts[:range] if opts[:range]
+    headers['Authorization'] = opts[:auth_head] if opts[:auth_head]
 
     cached.setup_headers(headers) if cached && (req_class == Net::HTTP::Get)
     req = req_class.new(uri.request_uri, headers)
-    req.basic_auth(uri.user, uri.password) if uri.user && uri.password
+    if uri.user && uri.password
+      req.basic_auth(uri.user, uri.password)
+      opts[:auth_head] = req['Authorization']
+    end
     req.body = opts[:body] if req_class == Net::HTTP::Post
     debug "prepared request: #{req.to_hash.inspect}"