summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-05 09:58:18 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-05 09:58:18 +0000
commit5504f490a6a2684bcacadee836c6933243e65a4f (patch)
treec916b860f0f8206a5375274be456725fc8c56b42
parentb50100a7697f6ad1a26217953d372ea0fcc11682 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--lib/open-uri.rb8
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d3144ee57b..8199b1cb55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 5 18:54:54 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb: Location: field may has a relative URI.
+ pointed out by erik eriksson <ee@opera.com>.
+
Wed Feb 5 17:11:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): no .<digit> floating literal anymore.
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