about summary refs log tree commit homepage
path: root/test/test_response.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_response.rb')
-rw-r--r--test/test_response.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_response.rb b/test/test_response.rb
index 8eb0736..d97fea8 100644
--- a/test/test_response.rb
+++ b/test/test_response.rb
@@ -4,12 +4,44 @@ require 'pp'
 require 'socket'
 require 'kcar'
 require 'digest/sha1'
+$stderr.sync = true
 
 class TestSession < Test::Unit::TestCase
   def setup
     @s, @c = UNIXSocket.pair
   end
 
+  def test_http_status_only_pipelined
+    resp = "HTTP/1.1 404 Not Found\r\n\r\n" \
+           "HTTP/1.1 404 Not Found\r\n\r\n"
+    pid = fork do
+      @s << resp
+      @s.close
+    end
+
+    @s.close
+    @response = Kcar::Response.new(@c)
+    status, headers, body = @response.rack
+    assert_equal status, "404 Not Found"
+    assert_equal({}, headers)
+    tmp = []
+    assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
+    assert_equal [], tmp
+    assert @response.parser.keepalive?
+    body.close
+
+    status, headers, body = @response.rack
+    assert_equal status, "404 Not Found"
+    assert_equal({},headers)
+    tmp = []
+    assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
+    assert_equal [], tmp
+
+    _, status = Process.waitpid2(pid)
+    assert status.success?
+    body.close
+  end
+
   def test_http_small_pipelined_identity
     resp = "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nhello world\n" \
            "HTTP/1.1 200 OK\r\nContent-Length: 14\r\n\r\ngoodbye world\n"