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