test/test_auto_chunk.rb in yahns-1.14.0 vs test/test_auto_chunk.rb in yahns-1.14.1

- old
+ new

@@ -16,11 +16,16 @@ cfg.instance_eval do GTL.synchronize do app = Rack::Builder.new do use Rack::ContentType, "text/plain" run(lambda do |env| - [ 200, {}, %w(a b c) ] + case env['PATH_INFO'] + when '/204' + [ 204, {}, [] ] + else + [ 200, {}, %w(a b c) ] + end end) end app(:rack, app) { listen "#{host}:#{port}" } end logger(Logger.new(err.path)) @@ -48,9 +53,24 @@ req = Net::HTTP::Get.new("/") res = http.request(req) assert_equal 200, res.code.to_i assert_equal 'abc', res.body end + + s = TCPSocket.new(host, port) + s.write("GET /204 HTTP/1.1\r\nHost: example.com\r\n\r\n") + buf = s.readpartial(1024) + assert_match %r{\r\n\r\n\z}, buf + refute_match %r{^Transfer-Encoding}i, buf + assert_match %r{^Connection: keep-alive\r\n}, buf + assert_nil IO.select([s], nil, nil, 1), 'connection persists..' + + # maek sure another on the same connection works + s.write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n") + buf = s.readpartial(1024) + assert_match %r{\AHTTP/1\.1 200}, buf + assert_match(%r{^Transfer-Encoding: chunked\r\n}, buf) + s.close ensure quit_wait(pid) end end