summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-27 17:16:06 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-27 17:16:06 +0000
commit2530fa50e9d4d0af08245481536d00d884d5766a (patch)
tree340e1a392e88bfef5e98f0330ceb54e4915c3382
parentaee4253e707542c8c0bf72558849ff2f5375e4f6 (diff)
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line):
ENV["REQUEST_URI"] is better to get correct Request-URI than ENV["SCRIPT_NAME"] + ENV["PATH_INFO"]. [ruby-dev:26235] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/webrick/cgi.rb12
-rw-r--r--test/webrick/test_cgi.rb7
-rw-r--r--test/webrick/webrick.cgi4
4 files changed, 24 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e008b67ede..18125ce3ea7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat May 28 02:00:11 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line):
+ ENV["REQUEST_URI"] is better to get correct Request-URI
+ than ENV["SCRIPT_NAME"] + ENV["PATH_INFO"]. [ruby-dev:26235]
+
Fri May 27 16:32:04 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/mkmf.rb: use the semicolon as the path separator
diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb
index cab237ab04a..21ffb7b89e7 100644
--- a/lib/webrick/cgi.rb
+++ b/lib/webrick/cgi.rb
@@ -150,15 +150,17 @@ module WEBrick
meth = @env["REQUEST_METHOD"] || "GET"
url = (@env["SCRIPT_NAME"] || File.expand_path($0)).dup
url << @env["PATH_INFO"].to_s
- url = WEBrick::HTTPUtils.escape_path(url)
- if query_string = @env["QUERY_STRING"]
- unless query_string.empty?
- url << "?" << query_string
+ unless url = @env["REQUEST_URI"]
+ url = WEBrick::HTTPUtils.escape_path(url)
+ if query_string = @env["QUERY_STRING"]
+ unless query_string.empty?
+ url << "?" << query_string
+ end
end
end
# we cannot get real HTTP version of client ;)
httpv = @config[:HTTPVersion]
- "#{meth} #{url} HTTP/#{httpv}"
+ return "#{meth} #{url} HTTP/#{httpv}"
end
def setup_header
diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb
index 60d5da6a726..082fe0f1908 100644
--- a/test/webrick/test_cgi.rb
+++ b/test/webrick/test_cgi.rb
@@ -16,6 +16,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
config = {
:CGIInterpreter => EnvUtil.rubybin,
:DocumentRoot => File.dirname(__FILE__),
+ :DirectoryIndex => ["webrick.cgi"],
}
TestWEBrick.start_httpserver(config){|server, addr, port|
http = Net::HTTP.new(addr, port)
@@ -41,6 +42,12 @@ class TestWEBrickCGI < Test::Unit::TestCase
req["Content-Type"] = "application/x-www-form-urlencoded"
http.request(req, "a=1&a=2&b=x"){|res|
assert_equal("a=1, a=2, b=x", res.body)}
+ req = Net::HTTP::Get.new("/")
+ http.request(req){|res|
+ ary = res.body.to_a
+ assert_match(%r{/$}, ary[0])
+ assert_match(%r{/webrick.cgi$}, ary[1])
+ }
}
end
end
diff --git a/test/webrick/webrick.cgi b/test/webrick/webrick.cgi
index ac525fb07d7..9edbb13847e 100644
--- a/test/webrick/webrick.cgi
+++ b/test/webrick/webrick.cgi
@@ -12,6 +12,10 @@ class TestApp < WEBrick::CGI
"#{key}=#{v}"
}.join(", ")
}.join(", ")
+ elsif %r{/$} =~ req.request_uri.to_s
+ res.body = ""
+ res.body << req.request_uri.to_s << "\n"
+ res.body << req.script_name
else
res.body = req.script_name
end