diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-24 00:14:54 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-24 00:14:54 +0000 |
commit | 77512a98814b8c8ae5e6314a8bdf30b1967d95d2 (patch) | |
tree | 0357097e0d3c017361aef16d18d89a32ac9a75fb /lib/rbot | |
parent | 4ee4a465fd25bd0d7e353f0f9e5b69fe165b3b30 (diff) |
Support basic_auth in httputil get and head methods
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/httputil.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/rbot/httputil.rb b/lib/rbot/httputil.rb index e80a45aa..18fc6a55 100644 --- a/lib/rbot/httputil.rb +++ b/lib/rbot/httputil.rb @@ -152,7 +152,11 @@ class HttpUtil begin proxy.start() {|http| yield uri.request_uri() if block_given? - resp = http.get(uri.request_uri(), @headers) + req = Net::HTTP::Get.new(uri.request_uri(), @headers) + if uri.user and uri.password + req.basic_auth(uri.user, uri.password) + end + resp = http.request(req) case resp when Net::HTTPSuccess if cache && !(resp.key?('cache-control') && resp['cache-control']=='must-revalidate') @@ -208,7 +212,11 @@ class HttpUtil begin proxy.start() {|http| yield uri.request_uri() if block_given? - resp = http.request_head(uri.request_uri(), @headers) + req = Net::HTTP::Head.new(uri.request_uri(), @headers) + if uri.user and uri.password + req.basic_auth(uri.user, uri.password) + end + resp = http.request(req) case resp when Net::HTTPSuccess return resp |