Bug #5737 » 204_304_keep_alive.patch
lib/webrick/httpresponse.rb | ||
---|---|---|
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"
|
test/webrick/test_httpresponse.rb | ||
---|---|---|
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
|