test/test_response.rb in kcar-0.1.1 vs test/test_response.rb in kcar-0.1.2
- old
+ new
@@ -2,13 +2,45 @@
require 'test/unit'
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"