3 t_plan
25 "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/
24 t_begin
"handles client EOF gracefully" && {
25 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
26 socat
- TCP4
:$listen > $tmp
28 if grep 'HTTP.* 500' $tmp
30 die
"500 error returned on client shutdown(SHUT_WR)"
37 t_begin
"two requests with keepalive" && {
38 curl
-sSfv http
://$listen/a http
://$listen/b
> $tmp 2>&1
44 t_begin
"reused existing connection" && {
45 grep 'Re-using existing connection' < $tmp
48 t_begin
"pipelining partial requests" && {
49 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
52 printf "$req"'\r\n'"$req"
54 printf 'Connection: close\r\n\r\n'
57 ) | socat
- TCP
:$listen > $fifo
61 t_begin
"two HTTP/1.1 responses" && {
62 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
65 t_begin
"two HTTP/1.1 200 OK responses" && {
66 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
69 t_begin
'one "Connection: keep-alive" response' && {
70 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
73 t_begin
'one "Connection: close" response' && {
74 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
77 t_begin
'check subshell success' && {
78 test x
"$(cat $ok)" = xok
82 t_begin
"check stderr" && {
86 t_begin
"burst pipelining requests" && {
87 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
90 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
93 ) | socat
- TCP
:$listen > $fifo
99 t_begin
"got 2 HTTP/1.1 responses from pipelining" && {
100 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
103 t_begin
"got 2 HTTP/1.1 200 OK responses" && {
104 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
107 t_begin
"one keepalive connection" && {
108 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
111 t_begin
"second request closes connection" && {
112 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
115 t_begin
"subshell exited correctly" && {
116 test x
"$(cat $ok)" = xok
119 t_begin
"stderr log has no errors" && {
123 t_begin
"HTTP/0.9 request should not return headers" && {
129 ) | socat
- TCP
:$listen > $fifo
135 t_begin
"env.inspect should've put everything on one line" && {
136 test 1 -eq $
(wc -l < $tmp)
139 t_begin
"no headers in output" && {
140 if grep ^Connection
: $tmp
142 die
"Connection header found in $tmp"
143 elif grep ^HTTP
/ $tmp
145 die
"HTTP/ found in $tmp"
149 t_begin
"killing succeeds" && {