4 echo "simple HTTP connection keepalive/pipelining tests for $model"
6 tbase
=$
(expr "$T" : '^\(t....\)-').ru
7 test -f "$tbase" || die
"$tbase missing for $T"
10 rtmpfiles unicorn_config pid r_err r_out tmp fifo ok
12 cat > $unicorn_config <<EOF
18 if test x
$model != xany
20 echo "Rainbows! { use :$model }" >> $unicorn_config
23 rainbows
-D $tbase -c $unicorn_config
27 curl
-sSfv http
://$listen/
30 echo "two requests with keepalive"
31 curl
-sSfv http
://$listen/a http
://$listen/b
> $tmp 2>&1
34 grep 'Re-using existing connection' < $tmp
36 echo "pipelining partial requests"
37 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
39 printf "$req"'\r\n'"$req"
42 printf 'Connection: close\r\n\r\n'
45 ) | socat
- TCP
:$listen > $fifo
49 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
50 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
51 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
52 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
53 test x
"$(cat $ok)" = xok
57 echo "burst pipelining"
58 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
60 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
64 ) | socat
- TCP
:$listen > $fifo
69 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
70 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
71 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
72 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
73 test x
"$(cat $ok)" = xok
77 echo "HTTP/0.9 request should not return headers"
79 printf 'GET /\r\n\r\n'
83 ) | socat
- TCP
:$listen > $fifo
87 echo "env.inspect should've put everything on one line"
88 test 1 -eq $
(wc -l < $tmp)
89 ! grep ^Connection
: $tmp