diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-05 09:58:18 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-05 09:58:18 +0000 |
commit | 5504f490a6a2684bcacadee836c6933243e65a4f (patch) | |
tree | c916b860f0f8206a5375274be456725fc8c56b42 /lib | |
parent | b50100a7697f6ad1a26217953d372ea0fcc11682 (diff) | |
download | ruby-5504f490a6a2684bcacadee836c6933243e65a4f.tar.gz |
* lib/open-uri.rb: Location: field may has a relative URI.
pointed out by erik eriksson <ee@opera.com>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/open-uri.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 2a72062574..e8cb3a24b2 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -130,7 +130,13 @@ module OpenURI uri.direct_open(buf, header) end rescue Redirect - uri = $!.uri + loc = $!.uri + if loc.relative? + # Although it violates RFC 2616, Location: field may have relative URI. + # It is converted to absolute URI using uri. + loc = uri + loc + end + uri = loc raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s uri_set[uri.to_s] = true retry |