From 77512a98814b8c8ae5e6314a8bdf30b1967d95d2 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 24 Oct 2006 00:14:54 +0000 Subject: [PATCH] Support basic_auth in httputil get and head methods --- lib/rbot/httputil.rb | 12 ++++++++++-- 1 file 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 -- 2.39.2