mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Prevents double headers from going out.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@415 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
d173a9c253
commit
b96bf4aeeb
2 changed files with 18 additions and 1 deletions
|
@ -322,12 +322,16 @@ module Mongrel
|
|||
attr_reader :out
|
||||
|
||||
def initialize(out)
|
||||
@sent = {}
|
||||
@out = out
|
||||
end
|
||||
|
||||
# Simply writes "#{key}: #{value}" to an output buffer.
|
||||
def[]=(key,value)
|
||||
@out.write(Const::HEADER_FORMAT % [key, value])
|
||||
if not @sent.has_key?(key)
|
||||
@sent[key] = true
|
||||
@out.write(Const::HEADER_FORMAT % [key, value])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,6 +37,19 @@ class ResponseTest < Test::Unit::TestCase
|
|||
assert io.length > 0, "output didn't have data"
|
||||
end
|
||||
|
||||
def test_response_duplicate_header_squash
|
||||
io = StringIO.new
|
||||
resp = HttpResponse.new(io)
|
||||
resp.start do |head,out|
|
||||
head["Content-Length"] = 30
|
||||
head["Content-Length"] = 0
|
||||
end
|
||||
|
||||
resp.finished
|
||||
|
||||
assert_equal io.length, 95, "too much output"
|
||||
end
|
||||
|
||||
def test_response_404
|
||||
io = StringIO.new
|
||||
|
||||
|
|
Loading…
Reference in a new issue