3 t_plan
24 "simple HTTP connection keepalive/pipelining tests for $model"
5 t_begin
"checking for config.ru for $model" && {
6 tbase
=simple-http_
$model.ru
10 t_begin
"setup and start" && {
12 rainbows
-D $tbase -c $unicorn_config
16 t_begin
"pid file exists" && {
20 t_begin
"single request" && {
21 curl
-sSfv http
://$listen/
26 t_begin
"two requests with keepalive" && {
27 curl
-sSfv http
://$listen/a http
://$listen/b
> $tmp 2>&1
33 t_begin
"reused existing connection" && {
34 grep 'Re-using existing connection' < $tmp
37 t_begin
"pipelining partial requests" && {
38 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
41 printf "$req"'\r\n'"$req"
43 printf 'Connection: close\r\n\r\n'
46 ) | socat
- TCP
:$listen > $fifo
50 t_begin
"two HTTP/1.1 responses" && {
51 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
54 t_begin
"two HTTP/1.1 200 OK responses" && {
55 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
58 t_begin
'one "Connection: keep-alive" response' && {
59 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
62 t_begin
'one "Connection: close" response' && {
63 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
66 t_begin
'check subshell success' && {
67 test x
"$(cat $ok)" = xok
71 t_begin
"check stderr" && {
75 t_begin
"burst pipelining requests" && {
76 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
79 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
82 ) | socat
- TCP
:$listen > $fifo
88 t_begin
"got 2 HTTP/1.1 responses from pipelining" && {
89 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
92 t_begin
"got 2 HTTP/1.1 200 OK responses" && {
93 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
96 t_begin
"one keepalive connection" && {
97 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
100 t_begin
"second request closes connection" && {
101 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
104 t_begin
"subshell exited correctly" && {
105 test x
"$(cat $ok)" = xok
108 t_begin
"stderr log has no errors" && {
112 t_begin
"HTTP/0.9 request should not return headers" && {
118 ) | socat
- TCP
:$listen > $fifo
124 t_begin
"env.inspect should've put everything on one line" && {
125 test 1 -eq $
(wc -l < $tmp)
128 t_begin
"no headers in output" && {
129 if grep ^Connection
: $tmp
131 die
"Connection header found in $tmp"
132 elif grep ^HTTP
/ $tmp
134 die
"HTTP/ found in $tmp"
138 t_begin
"killing succeeds" && {