Skip to content

Commit

Permalink
test_puma_server.rb - add 3 '404 empty body' tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Mar 30, 2023
1 parent 91ad03d commit 1aa498d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test_puma_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1545,4 +1545,25 @@ def test_streaming_enum_body_2
assert_equal str * loops, resp_body
assert_operator times.last - times.first, :>, 1.0
end

def test_empty_body_array_content_length_0
server_run { |env| [404, {'Content-Length' => '0'}, []] }

resp = send_http_and_sysread "GET / HTTP/1.1\r\n\r\n"
assert_equal "HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n", resp
end

def test_empty_body_array_no_content_length
server_run { |env| [404, {}, []] }

resp = send_http_and_sysread "GET / HTTP/1.1\r\n\r\n"
assert_equal "HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n", resp
end

def test_empty_body_enum
server_run { |env| [404, {}, [].to_enum] }

resp = send_http_and_sysread "GET / HTTP/1.1\r\n\r\n"
assert_equal "HTTP/1.1 404 Not Found\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n", resp
end
end

0 comments on commit 1aa498d

Please sign in to comment.