3 t_plan
19 "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" && {
13 echo "listen '$unix_socket'" >> $unicorn_config
14 rainbows
-D $tbase -c $unicorn_config
18 t_begin
"pid file exists" && {
22 t_begin
"single TCP request" && {
23 curl
-sSfv http
://$listen/
26 t_begin
"handles client EOF gracefully" && {
27 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
28 socat
- UNIX
:$unix_socket > $tmp
30 if grep 'HTTP.* 500' $tmp
32 die
"500 error returned on client shutdown(SHUT_WR)"
39 t_begin
"pipelining partial requests" && {
40 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
43 printf "$req"'\r\n'"$req"
45 printf 'Connection: close\r\n\r\n'
48 ) | socat
- UNIX
:$unix_socket > $fifo
52 t_begin
"two HTTP/1.1 responses" && {
53 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
56 t_begin
"two HTTP/1.1 200 OK responses" && {
57 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
60 t_begin
'one "Connection: keep-alive" response' && {
61 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
64 t_begin
'one "Connection: close" response' && {
65 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
68 t_begin
'check subshell success' && {
69 test x
"$(cat $ok)" = xok
73 t_begin
"check stderr" && {
77 t_begin
"burst pipelining requests" && {
78 req
='GET / HTTP/1.1\r\nHost: example.com\r\n'
81 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
84 ) | socat
- UNIX
:$unix_socket > $fifo
90 t_begin
"two HTTP/1.1 responses" && {
91 test 2 -eq $
(grep '^HTTP/1.1' $tmp |
wc -l)
94 t_begin
"two HTTP/1.1 200 OK responses" && {
95 test 2 -eq $
(grep '^HTTP/1.1 200 OK' $tmp |
wc -l)
98 t_begin
'one "Connection: keep-alive" response' && {
99 test 1 -eq $
(grep '^Connection: keep-alive' $tmp |
wc -l)
102 t_begin
'one "Connection: close" response' && {
103 test 1 -eq $
(grep '^Connection: close' $tmp |
wc -l)
106 t_begin
'check subshell success' && {
107 test x
"$(cat $ok)" = xok
110 t_begin
"killing succeeds" && {