summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-13 22:30:01 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-13 22:30:01 +0000
commit61f0ebb3a600888439c2f5d81e2b31daa704bf8d (patch)
treeea70fb1035b731eb8e4a9a5cdaeaeaa5996d11a0 /lib
parentfee27a0274be28bf32129ed922c80d0a0993cc9a (diff)
Minor tweaks to httputil: make last response available in @last_resp for get and head methods when they return nil
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/httputil.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rbot/httputil.rb b/lib/rbot/httputil.rb
index 6383d4e2..ddbd8227 100644
--- a/lib/rbot/httputil.rb
+++ b/lib/rbot/httputil.rb
@@ -45,7 +45,9 @@ class HttpUtil
@headers = {
'User-Agent' => "rbot http util #{$version} (http://linuxbrit.co.uk/rbot/)",
}
+ @last_response = nil
end
+ attr_reader :last_response
# if http_proxy_include or http_proxy_exclude are set, then examine the
# uri to see if this is a proxied uri
@@ -178,12 +180,14 @@ class HttpUtil
else
debug "HttpUtil.get return code #{resp.code} #{resp.body}"
end
+ @last_response = resp
return nil
}
rescue StandardError, Timeout::Error => e
error "HttpUtil.get exception: #{e.inspect}, while trying to get #{uri}"
debug e.backtrace.join("\n")
end
+ @last_response = nil
return nil
end
@@ -202,7 +206,7 @@ class HttpUtil
begin
proxy.start() {|http|
yield uri.request_uri() if block_given?
- resp = http.head(uri.request_uri(), @headers)
+ resp = http.request_head(uri.request_uri(), @headers)
case resp
when Net::HTTPSuccess
return resp
@@ -217,12 +221,14 @@ class HttpUtil
else
debug "HttpUtil.head return code #{resp.code}"
end
+ @last_response = resp
return nil
}
rescue StandardError, Timeout::Error => e
error "HttpUtil.head exception: #{e.inspect}, while trying to get #{uri}"
debug e.backtrace.join("\n")
end
+ @last_response = nil
return nil
end