1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/webrick/httpresponse.rb (setup_header): 204 and 304 responses

are allowed to have a Keep-Alive connection. [ruby-core:41581]

* test/webrick/test_httpresponse.rb: corresponding test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2011-12-12 22:15:31 +00:00
parent 0f9662f366
commit 6ef323d6f8
3 changed files with 54 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Tue Dec 13 07:13:28 2011 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/webrick/httpresponse.rb (setup_header): 204 and 304 responses
are allowed to have a Keep-Alive connection. [ruby-core:41581]
* test/webrick/test_httpresponse.rb: corresponding test.
Tue Dec 13 06:29:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_magic_comment): should pass the proper value.

View file

@ -202,7 +202,7 @@ module WEBrick
if @header['connection'] == "close"
@keep_alive = false
elsif keep_alive?
if chunked? || @header['content-length']
if chunked? || @header['content-length'] || @status == 304 || @status == 204
@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"

View file

@ -0,0 +1,46 @@
require "webrick"
require "minitest/autorun"
module WEBrick
class TestHTTPResponse < MiniTest::Unit::TestCase
class FakeLogger
attr_reader :messages
def initialize
@messages = []
end
def warn msg
@messages << msg
end
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
end
end