test/test_proxy_pass.rb in yahns-1.14.0 vs test/test_proxy_pass.rb in yahns-1.14.1
- old
+ new
@@ -152,10 +152,13 @@
[ 403, [ %w(Content-Type text/html), %w(Content-Length 0) ], [] ]
when '/forbidden-put-abort'
env['rack.hijack'].call.close
# should not be seen:
[ 123, [ %w(Content-Type text/html), %w(Content-Length 0) ], [] ]
+ when '/204'
+ buf = env['rack.input'].read # drain
+ [ 204, {}, [] ]
else
buf = env['rack.input'].read
[ 201, {
'Content-Length' => buf.bytesize.to_s,
'Content-Type' => 'text/plain',
@@ -269,10 +272,11 @@
end
stderr_path err.path
end
end
+ check_204_on_put(host, port)
check_forbidden_put(host, port)
check_eof_body(host, port)
check_pipelining(host, port)
check_response_trailer(host, port)
@@ -636,7 +640,36 @@
assert_raises(EOFError) { s.readpartial(1) }
@err.truncate(0)
end
ensure
to_close.each(&:close)
+ end
+
+ def check_204_on_put(host, port)
+ s = TCPSocket.new(host, port)
+ s.write("PUT /204 HTTP/1.1\r\nHost: example.com\r\n" \
+ "Content-Length: 11\r\n" \
+ "Content-Type: application/octet-stream\r\n" \
+ "\r\nhello worldPUT")
+ buf = s.readpartial(1024)
+ assert_match %r{\AHTTP/1\.1 204}, buf
+ assert_match %r{\r\n\r\n\z}, buf
+ refute_match %r{^Transfer-Encoding}i, buf
+ refute_match %r{^Content-Length}i, buf
+ assert_match %r{^Connection: keep-alive\r\n}, buf
+ assert_nil IO.select([s], nil, nil, 1), 'connection persists..'
+
+ # make sure another on the same connection works
+ s.write(" / HTTP/1.1\r\nHost: example.com\r\n" \
+ "Content-Length: 11\r\n" \
+ "Content-Type: application/octet-stream\r\n" \
+ "\r\nhello world")
+ buf = s.readpartial(1024)
+ assert_match %r{\r\n\r\nhello world\z}, buf
+ assert_match %r{\AHTTP/1\.1 201}, buf
+ assert_match(%r{^Content-Length: 11\r\n}, buf)
+ assert_match %r{^Connection: keep-alive\r\n}, buf
+ assert_nil IO.select([s], nil, nil, 1), 'connection persists..'
+ ensure
+ s.close if s
end
end