summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-22 12:49:34 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-22 12:49:34 +0000
commit11b4be8e077f2fa1b755051087b9e8cb92a5a1c0 (patch)
tree348ea8fadb10359bad4411022a1e1c187dd92675
parente0a17f3b054667054724f621a101d1cd4cc7fbd4 (diff)
merge revision(s) 32593:
* lib/webrick/httprequest.rb (WEBrick::HTTPRequest#each): Allow HTTP/0.9 request which doesn't has any header or body. patched by Felix Jodoin. [ruby-core:38040] [Bug #5022] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/webrick/httprequest.rb10
-rw-r--r--test/webrick/test_httprequest.rb9
3 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b32f7419f..f6f5cc9b81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Jul 22 21:49:28 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#each):
+ Allow HTTP/0.9 request which doesn't has any header or body.
+ patched by Felix Jodoin. [ruby-core:38040] [Bug #5022]
+
Fri Jul 22 21:45:21 2011 NARUSE, Yui <naruse@ruby-lang.org>
* ext/dl/handle.c (dlhandle_sym): clear previous error with dlerror()
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb
index 1e8789d2d6..050b5ed45b 100644
--- a/lib/webrick/httprequest.rb
+++ b/lib/webrick/httprequest.rb
@@ -179,10 +179,12 @@ module WEBrick
# Iterates over the request headers
def each
- @header.each{|k, v|
- value = @header[k]
- yield(k, value.empty? ? nil : value.join(", "))
- }
+ if @header
+ @header.each{|k, v|
+ value = @header[k]
+ yield(k, value.empty? ? nil : value.join(", "))
+ }
+ end
end
##
diff --git a/test/webrick/test_httprequest.rb b/test/webrick/test_httprequest.rb
index d8467d4b4e..0ce6b4f40f 100644
--- a/test/webrick/test_httprequest.rb
+++ b/test/webrick/test_httprequest.rb
@@ -3,6 +3,15 @@ require "stringio"
require "test/unit"
class TestWEBrickHTTPRequest < Test::Unit::TestCase
+ def test_simple_request
+ msg = <<-_end_of_message_
+GET /
+ _end_of_message_
+ req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+ req.parse(StringIO.new(msg))
+ assert(req.meta_vars) # fails if @header was not initialized and iteration is attempted on the nil reference
+ end
+
def test_parse_09
msg = <<-_end_of_message_
GET /