diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-13 20:40:46 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-13 20:40:46 +0000 |
commit | fb688693c060e3e82705267363ee83b64c8cbdca (patch) | |
tree | f6babce633b6d8d28bf381ac77ea9fe40dd3116a /lib/custodian/protocol-tests/http.rb | |
parent | f0dff8eb742441901f6a88bf0ce078efe60e4085 (diff) |
follow redirects
Diffstat (limited to 'lib/custodian/protocol-tests/http.rb')
-rwxr-xr-x | lib/custodian/protocol-tests/http.rb | 12 |
1 files changed, 10 insertions, 2 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 |