more consistent use/avoidance of HeaderHash
[rainbows.git] / t / t0050-response-body-close-has-env.sh
blob4d0cd6f620279a0912a4e5d8021725c00a8a91e3
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 29 "keepalive does not clear Rack env prematurely for $model"
6 t_begin "setup and start" && {
7 rainbows_setup
8 rtmpfiles curl_out curl_err
9 echo "preload_app true" >> $unicorn_config
10 rainbows -D close-has-env.ru -c $unicorn_config
11 rainbows_wait_start
14 req_pipelined () {
15 pfx=$1
16 t_begin "make pipelined requests to trigger $pfx response body" && {
17 > $r_out
19 cat $fifo > $tmp &
20 printf 'GET /%s/1 HTTP/1.1\r\n' $pfx
21 printf 'Host: example.com\r\n\r\n'
22 printf 'GET /%s/2 HTTP/1.1\r\n' $pfx
23 printf 'Host: example.com\r\n\r\n'
24 printf 'GET /%s/3 HTTP/1.1\r\n' $pfx
25 printf 'Host: example.com\r\n'
26 printf 'Connection: close\r\n\r\n'
27 wait
28 echo ok > $ok
29 ) | socat - TCP4:$listen > $fifo
30 test xok = x$(cat $ok)
34 reload () {
35 t_begin 'reloading Rainbows! to ensure writeout' && {
36 # reload to ensure everything is flushed
37 kill -HUP $rainbows_pid
38 test xSTART = x"$(cat $fifo)"
42 check_log () {
43 pfx="$1"
44 t_begin "check body close messages" && {
45 < $r_out awk '
46 /^path_info=\/'$pfx'\/[1-3]$/ { next }
47 { exit(2) }
48 END { exit(NR == 3 ? 0 : 1) }
53 req_keepalive () {
54 pfx="$1"
55 t_begin "make keepalive requests to trigger $pfx response body" && {
56 > $r_out
57 rm -f $curl_err $curl_out
58 curl -vsSf http://$listen/$pfx/[1-3] 2> $curl_err > $curl_out
62 req_keepalive file
63 reload
64 check_log file
66 req_pipelined file
67 reload
68 check_log file
70 req_keepalive blob
71 reload
72 check_log blob
74 req_pipelined blob
75 reload
76 check_log blob
78 req_keepalive pipe
79 reload
80 check_log pipe
82 req_pipelined pipe
83 reload
84 check_log pipe
86 t_begin "enable sendfile gem" && {
87 echo "require 'sendfile'" >> $unicorn_config
88 curl http://$listen/ >/dev/null # ensure worker is loaded before HUP
91 reload
93 req_keepalive file
94 reload
95 check_log file
97 req_pipelined file
98 reload
99 check_log file
101 t_begin "killing succeeds" && {
102 kill $rainbows_pid
105 t_begin "check stderr" && {
106 check_stderr
109 t_done