mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Don't omit empty header values. (#1261)
* Don't omit empty header values. ''.split => [] so no header would be appended. * Add test for empty header values.
This commit is contained in:
parent
de870595d0
commit
eea4dbb437
2 changed files with 16 additions and 1 deletions
|
@ -689,7 +689,7 @@ module Puma
|
|||
next
|
||||
end
|
||||
|
||||
if vs.respond_to?(:to_s)
|
||||
if vs.respond_to?(:to_s) && !vs.to_s.empty?
|
||||
vs.to_s.split(NEWLINE).each do |v|
|
||||
lines.append k, colon, v, line_ending
|
||||
end
|
||||
|
|
|
@ -623,4 +623,19 @@ class TestPumaServer < Minitest::Test
|
|||
assert_equal "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", data
|
||||
assert_equal "hello", body
|
||||
end
|
||||
|
||||
def test_empty_header_values
|
||||
@server.app = proc { |env| [200, {"X-Empty-Header" => ""}, []] }
|
||||
|
||||
@server.add_tcp_listener @host, @port
|
||||
@server.run
|
||||
|
||||
sock = TCPSocket.new @host, @server.connected_port
|
||||
|
||||
sock << "HEAD / HTTP/1.0\r\n\r\n"
|
||||
|
||||
data = sock.read
|
||||
|
||||
assert_equal "HTTP/1.0 200 OK\r\nX-Empty-Header: \r\n\r\n", data
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue