* 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/trunk@32593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-07-21 08:27:08 +00:00
Родитель 4aa9e1ace0
Коммит 2dfc9e1626
3 изменённых файлов: 21 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Thu Jul 21 17:14:21 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]
Wed Jul 20 23:02:18 2011 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* io.c (rb_update_max_fd): remove parentheses. they are not in

Просмотреть файл

@ -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
##

Просмотреть файл

@ -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 /