summaryrefslogtreecommitdiff
path: root/lib/custodian/protocol-tests
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-13 20:40:46 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-13 20:40:46 +0000
commitc2e2c7a771ca967e680ad5c45b9392957655a7d4 (patch)
treef6babce633b6d8d28bf381ac77ea9fe40dd3116a /lib/custodian/protocol-tests
parent21967ea467b4487606ad4e35a4bbc71c0d73792a (diff)
follow redirects
Diffstat (limited to 'lib/custodian/protocol-tests')
-rwxr-xr-xlib/custodian/protocol-tests/http.rb12
-rwxr-xr-xlib/custodian/protocol-tests/https.rb12
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/custodian/protocol-tests/http.rb b/lib/custodian/protocol-tests/http.rb
index f08856d..c7910c5 100755
--- a/lib/custodian/protocol-tests/http.rb
+++ b/lib/custodian/protocol-tests/http.rb
@@ -128,8 +128,16 @@ class HTTPTest
response = http.start { http.get("#{url.path}?#{url.query}") }
end
- @status = response.code.to_i
- @body = response.body
+ case response
+ when Net::HTTPRedirection
+ then
+ newURL = response['location'].match(/^http/)?
+ response['Location']:uri_str+response['Location']
+ return( getURL(newURL) )
+ else
+ @status = response.code.to_i
+ @body = response.body
+ end
return true
rescue Errno::EHOSTUNREACH => ex
diff --git a/lib/custodian/protocol-tests/https.rb b/lib/custodian/protocol-tests/https.rb
index 6c4a53a..0935ebb 100755
--- a/lib/custodian/protocol-tests/https.rb
+++ b/lib/custodian/protocol-tests/https.rb
@@ -129,8 +129,16 @@ class HTTPSTest
response = http.start { http.get("#{url.path}?#{url.query}") }
end
- @status = response.code.to_i
- @body = response.body
+ case response
+ when Net::HTTPRedirection
+ then
+ newURL = response['location'].match(/^http/)?
+ response['Location']:uri_str+response['Location']
+ return( getURL(newURL) )
+ else
+ @status = response.code.to_i
+ @body = response.body
+ end
return true
rescue Errno::EHOSTUNREACH => ex