[前][次][番号順一覧][スレッド一覧]

ruby-changes:20545

From: naruse <ko1@a...>
Date: Thu, 21 Jul 2011 17:27:23 +0900 (JST)
Subject: [ruby-changes:20545] naruse:r32593 (trunk): * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#each):

naruse	2011-07-21 17:27:08 +0900 (Thu, 21 Jul 2011)

  New Revision: 32593

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32593

  Log:
    * 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:
    trunk/ChangeLog
    trunk/lib/webrick/httprequest.rb
    trunk/test/webrick/test_httprequest.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32592)
+++ ChangeLog	(revision 32593)
@@ -1,3 +1,9 @@
+Thu Jul 21 17:14:21 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]
+
 Wed Jul 20 23:02:18 2011  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* io.c (rb_update_max_fd): remove parentheses. they are not in
Index: lib/webrick/httprequest.rb
===================================================================
--- lib/webrick/httprequest.rb	(revision 32592)
+++ lib/webrick/httprequest.rb	(revision 32593)
@@ -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: test/webrick/test_httprequest.rb
===================================================================
--- test/webrick/test_httprequest.rb	(revision 32592)
+++ test/webrick/test_httprequest.rb	(revision 32593)
@@ -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/

[前][次][番号順一覧][スレッド一覧]