6 class TestTeeInput < Test::Unit::TestCase
12 @rd.sync = @wr.sync = true
17 return if $$ != @start_pid
29 init_parser("hello", 5 + (4096 * 4 * 3) + "#$/foo#$/".size)
30 ti = Unicorn::TeeInput.new(@rd)
34 3.times { @wr.write("ffff" * 4096) }
39 assert_nothing_raised { line = ti.gets }
40 assert_equal(4096 * 4 * 3 + 5 + $/.size, line.size)
41 assert_equal("hello" << ("ffff" * 4096 * 3) << "#$/", line)
42 assert_nothing_raised { line = ti.gets }
43 assert_equal "foo#$/", line
45 assert_nothing_raised { pid, status = Process.waitpid2(pid) }
46 assert status.success?
50 init_parser("hello", 5 + "#$/foo".size)
51 ti = Unicorn::TeeInput.new(@rd)
59 assert_nothing_raised { line = ti.gets }
60 assert_equal("hello#$/", line)
61 assert_nothing_raised { line = ti.gets }
62 assert_equal "foo", line
64 assert_nothing_raised { pid, status = Process.waitpid2(pid) }
65 assert status.success?
70 def init_parser(body, size = nil)
71 @parser = Unicorn::TeeInput::PARSER
73 body = body.to_s.freeze
74 buf = "POST / HTTP/1.1\r\n" \
75 "Host: localhost\r\n" \
76 "Content-Length: #{size || body.size}\r\n" \
78 buf = Unicorn::TeeInput::RAW.replace(buf)
79 assert_equal @env, @parser.headers(@env, buf)
80 assert_equal body, buf