support for Rack hijack in request and response
[unicorn.git] / t / t0002-parser-error.sh
blob9fa5a31a77e1298ab83a7edab4627c0570641e0c
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 11 "parser error test"
5 t_begin "setup and startup" && {
6 unicorn_setup
7 unicorn -D env.ru -c $unicorn_config
8 unicorn_wait_start
11 t_begin "send a bad request" && {
13 printf 'GET / HTTP/1/1\r\nHost: example.com\r\n\r\n'
14 cat $fifo > $tmp &
15 wait
16 echo ok > $ok
17 ) | socat - TCP:$listen > $fifo
18 test xok = x$(cat $ok)
21 dbgcat tmp
23 t_begin "response should be a 400" && {
24 grep -F 'HTTP/1.1 400 Bad Request' $tmp
27 t_begin "send a huge Request URI (REQUEST_PATH > (12 * 1024))" && {
28 rm -f $tmp
29 cat $fifo > $tmp &
31 set -e
32 trap 'echo ok > $ok' EXIT
33 printf 'GET /'
34 for i in $(awk </dev/null 'BEGIN{for(i=0;i<1024;i++) print i}')
36 printf '0123456789ab'
37 done
38 printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
39 ) | socat - TCP:$listen > $fifo || :
40 test xok = x$(cat $ok)
41 wait
44 t_begin "response should be a 414 (REQUEST_PATH)" && {
45 grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
48 t_begin "send a huge Request URI (QUERY_STRING > (10 * 1024))" && {
49 rm -f $tmp
50 cat $fifo > $tmp &
52 set -e
53 trap 'echo ok > $ok' EXIT
54 printf 'GET /hello-world?a'
55 for i in $(awk </dev/null 'BEGIN{for(i=0;i<1024;i++) print i}')
57 printf '0123456789'
58 done
59 printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
60 ) | socat - TCP:$listen > $fifo || :
61 test xok = x$(cat $ok)
62 wait
65 t_begin "response should be a 414 (QUERY_STRING)" && {
66 grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
69 t_begin "send a huge Request URI (FRAGMENT > 1024)" && {
70 rm -f $tmp
71 cat $fifo > $tmp &
73 set -e
74 trap 'echo ok > $ok' EXIT
75 printf 'GET /hello-world#a'
76 for i in $(awk </dev/null 'BEGIN{for(i=0;i<64;i++) print i}')
78 printf '0123456789abcdef'
79 done
80 printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
81 ) | socat - TCP:$listen > $fifo || :
82 test xok = x$(cat $ok)
83 wait
86 t_begin "response should be a 414 (FRAGMENT)" && {
87 grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
90 t_begin "server stderr should be clean" && check_stderr
92 t_begin "term signal sent" && kill $unicorn_pid
94 t_done