summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-08 17:14:54 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-08 17:14:54 +0000
commit9c6be0ed315a53cd7d9a10e4c682f94afabd6c3d (patch)
tree63bcee0ea13ce78e5892e3ae1357d92f6dd0f13a /lib
parent0109f67cc75ceded351b0023c6fb77d9bcccbcd1 (diff)
HttpUtil: preserve authorization across redirects
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/utils/httputil.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
index 2b714527..11f3cb41 100644
--- a/lib/rbot/core/utils/httputil.rb
+++ b/lib/rbot/core/utils/httputil.rb
@@ -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}"