ruby-changes:20577
From: naruse <ko1@a...>
Date: Fri, 22 Jul 2011 21:49:46 +0900 (JST)
Subject: [ruby-changes:20577] naruse:r32625 (ruby_1_9_3): merge revision(s) 32593:
naruse 2011-07-22 21:49:34 +0900 (Fri, 22 Jul 2011) New Revision: 32625 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32625 Log: 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] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/lib/webrick/httprequest.rb branches/ruby_1_9_3/test/webrick/test_httprequest.rb Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32624) +++ ruby_1_9_3/ChangeLog (revision 32625) @@ -1,3 +1,9 @@ +Fri Jul 22 21:49:28 2011 NARUSE, Yui <naruse@r...> + + * 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@r...> * ext/dl/handle.c (dlhandle_sym): clear previous error with dlerror() Index: ruby_1_9_3/lib/webrick/httprequest.rb =================================================================== --- ruby_1_9_3/lib/webrick/httprequest.rb (revision 32624) +++ ruby_1_9_3/lib/webrick/httprequest.rb (revision 32625) @@ -179,10 +179,12 @@ # 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 ## Index: ruby_1_9_3/test/webrick/test_httprequest.rb =================================================================== --- ruby_1_9_3/test/webrick/test_httprequest.rb (revision 32624) +++ ruby_1_9_3/test/webrick/test_httprequest.rb (revision 32625) @@ -3,6 +3,15 @@ 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 / -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/