3 skip_models StreamResponseEpoll
4 t_plan
25 "simple HTTP connection keepalive/pipelining tests for $model"
6 t_begin
"checking for config.ru for $model" && {
7 tbase
=simple-http_
$model.ru
11 t_begin
"setup and start" && {
13 rainbows
-D $tbase -c $unicorn_config
17 t_begin
"pid file exists" && {
21 t_begin
"single request" && {
22 curl
-sSfv http
://$listen/
25 t_begin
"handles client EOF gracefully" && {
26 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
27 socat
- TCP4
:$listen > $tmp
29 if grep 'HTTP.* 500' $tmp
31 die
"500 error returned on client shutdown(SHUT_WR)"
38 t_begin
"two requests with keepalive" && {
39 curl
-sSfv http
://$listen/a http
://$listen/b
> $tmp 2>&1
45 t_begin
"reused existing connection" && {
46 grep 'Re-using existing connection' < $tmp
49 t_begin
"pipelining partial requests" && {
50 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
53 printf "$req"'\r\n'"$req"
55 printf 'Connection: close\r\n\r\n'
58 ) | socat
- TCP
:$listen > $fifo
62 t_begin
"two HTTP/1.1 responses" && {
63 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
66 t_begin
"two HTTP/1.1 200 OK responses" && {
67 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
70 t_begin
'one "Connection: keep-alive" response' && {
71 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
74 t_begin
'one "Connection: close" response' && {
75 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
78 t_begin
'check subshell success' && {
79 test x
"$(cat $ok)" = xok
83 t_begin
"check stderr" && {
87 t_begin
"burst pipelining requests" && {
88 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
91 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
94 ) | socat
- TCP
:$listen > $fifo
100 t_begin
"got 2 HTTP/1.1 responses from pipelining" && {
101 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
104 t_begin
"got 2 HTTP/1.1 200 OK responses" && {
105 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
108 t_begin
"one keepalive connection" && {
109 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
112 t_begin
"second request closes connection" && {
113 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
116 t_begin
"subshell exited correctly" && {
117 test x
"$(cat $ok)" = xok
120 t_begin
"stderr log has no errors" && {
124 t_begin
"HTTP/0.9 request should not return headers" && {
130 ) | socat
- TCP
:$listen > $fifo
136 t_begin
"env.inspect should've put everything on one line" && {
137 test 1 -eq $
(wc -l < $tmp)
140 t_begin
"no headers in output" && {
141 if grep ^Connection
: $tmp
143 die
"Connection header found in $tmp"
144 elif grep ^HTTP
/ $tmp
146 die
"HTTP/ found in $tmp"
150 t_begin
"killing succeeds" && {