1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| | #!/bin/sh
. ./test-lib.sh
skip_models StreamResponseEpoll
t_plan 11 "client_max_header_size tests for $model"
t_begin "setup Rainbows!" && {
rainbows_setup $model
}
t_begin "fails with zero size" && {
ed -s $unicorn_config <<EOF
,s/^ client_max_body_size.*/ client_max_header_size 0/
w
EOF
grep "client_max_header_size 0" $unicorn_config
rainbows -D env.ru -c $unicorn_config && die "should fail"
}
t_begin "fails with negative value" && {
ed -s $unicorn_config <<EOF
,s/^ client_max_header_size.*/ client_max_header_size -1/
w
EOF
grep "client_max_header_size -1" $unicorn_config
rainbows -D env.ru -c $unicorn_config && die "should fail"
}
t_begin "fails with small size" && {
ed -s $unicorn_config <<EOF
,s/^ client_max_header_size.*/ client_max_header_size 7/
w
EOF
grep "client_max_header_size 7" $unicorn_config
rainbows -D env.ru -c $unicorn_config && die "should fail"
}
t_begin "starts with minimum value" && {
ed -s $unicorn_config <<EOF
,s/^ client_max_header_size.*/ client_max_header_size 8/
w
EOF
grep 'client_max_header_size 8$' $unicorn_config
rainbows -D env.ru -c $unicorn_config
rainbows_wait_start
}
t_begin "smallest HTTP/0.9 request works right" && {
(
cat $fifo > $tmp &
printf 'GET /\r\n'
wait
echo ok > $ok
) | socat - TCP:$listen > $fifo
wait
test xok = x"$(cat $ok)"
test 1 -eq $(count_lines < $tmp)
grep HTTP_VERSION $tmp && die "unexpected HTTP_VERSION in HTTP/0.9 request"
}
t_begin "HTTP/1.1 request fails" && {
curl -vsSf http://$listen/ > $tmp 2>&1 && die "unexpected curl success"
grep '400$' $tmp
}
t_begin "increase client_max_header_size on reload" && {
ed -s $unicorn_config <<EOF
,s/^ client_max_header_size.*/ client_max_header_size 512/
w
EOF
grep 'client_max_header_size 512$' $unicorn_config
kill -HUP $rainbows_pid
test xSTART = x"$(cat $fifo)"
}
t_begin "HTTP/1.1 request succeeds" && {
curl -sSf http://$listen/ > $tmp
test 1 -eq $(count_lines < $tmp)
dbgcat tmp
}
t_begin "no errors in stderr" && {
check_stderr
}
t_begin "shutdown" && {
kill $rainbows_pid
}
t_done
|