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 | 5f2ecd7674790edaf19ba1c73c60f51d88b70769 (patch) | |
| tree | c916b860f0f8206a5375274be456725fc8c56b42 /lib | |
| parent | 275a8ffd22735c847723218879dc4a96d06a9eaf (diff) | |
| download | ruby-5f2ecd7674790edaf19ba1c73c60f51d88b70769.tar.gz ruby-5f2ecd7674790edaf19ba1c73c60f51d88b70769.tar.xz ruby-5f2ecd7674790edaf19ba1c73c60f51d88b70769.zip | |
* lib/open-uri.rb: Location: field may has a relative URI.
pointed out by erik eriksson <ee@opera.com>.
git-svn-id: http://svn.ruby-lang.org/repos/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 2a7206257..e8cb3a24b 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 |
