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

ruby-changes:21975

From: tenderlove <ko1@a...>
Date: Tue, 13 Dec 2011 07:34:11 +0900 (JST)
Subject: [ruby-changes:21975] tenderlove:r34024 (trunk): * lib/webrick/httpresponse.rb (setup_header): 1xx responses

tenderlove	2011-12-13 07:33:56 +0900 (Tue, 13 Dec 2011)

  New Revision: 34024

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

  Log:
    * lib/webrick/httpresponse.rb (setup_header): 1xx responses
      are allowed to have Keep-Alive connections.
    
    * test/webrick/test_httpresponse.rb: corresponding test.

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/httpresponse.rb
    trunk/test/webrick/test_httpresponse.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34023)
+++ ChangeLog	(revision 34024)
@@ -1,3 +1,10 @@
+Tue Dec 13 07:30:14 2011  Aaron Patterson <aaron@t...>
+
+	* lib/webrick/httpresponse.rb (setup_header): 1xx responses
+	  are allowed to have Keep-Alive connections.
+	
+	* test/webrick/test_httpresponse.rb: corresponding test.
+
 Tue Dec 13 07:13:28 2011  Aaron Patterson <aaron@t...>
 
 	* lib/webrick/httpresponse.rb (setup_header): 204 and 304 responses
Index: lib/webrick/httpresponse.rb
===================================================================
--- lib/webrick/httpresponse.rb	(revision 34023)
+++ lib/webrick/httpresponse.rb	(revision 34024)
@@ -202,7 +202,7 @@
       if @header['connection'] == "close"
          @keep_alive = false
       elsif keep_alive?
-        if chunked? || @header['content-length'] || @status == 304 || @status == 204
+        if chunked? || @header['content-length'] || @status == 304 || @status == 204 || HTTPStatus.info?(@status)
           @header['connection'] = "Keep-Alive"
         else
           msg = "Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true"
Index: test/webrick/test_httpresponse.rb
===================================================================
--- test/webrick/test_httpresponse.rb	(revision 34023)
+++ test/webrick/test_httpresponse.rb	(revision 34024)
@@ -15,29 +15,32 @@
       end
     end
 
+    attr_reader :config, :logger, :res
+
+    def setup
+      super
+      @logger          = FakeLogger.new
+      @config          = Config::HTTP
+      @config[:Logger] = logger
+      @res             = HTTPResponse.new config
+      @res.keep_alive  = true
+    end
+
     def test_304_does_not_log_warning
-      logger          = FakeLogger.new
-      config          = Config::HTTP
-      config[:Logger] = logger
-
-      res             = HTTPResponse.new config
       res.status      = 304
-      res.keep_alive  = true
-
       res.setup_header
-
       assert_equal 0, logger.messages.length
     end
 
     def test_204_does_not_log_warning
-      logger          = FakeLogger.new
-      config          = Config::HTTP
-      config[:Logger] = logger
-
-      res             = HTTPResponse.new config
       res.status      = 204
-      res.keep_alive  = true
+      res.setup_header
 
+      assert_equal 0, logger.messages.length
+    end
+
+    def test_1xx_does_not_log_warnings
+      res.status      = 105
       res.setup_header
 
       assert_equal 0, logger.messages.length

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

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