about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-04 16:41:36 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-04 16:41:36 -0700
commitf81aa02448b615c4d5fc4f6544c53289dae9d2ec (patch)
treeca8b4d49e5baaedb7106932c3fc73d0078e5a0d1 /t
parent3a76dc40dda91a3804276fcc73260bb2a529c034 (diff)
downloadunicorn-f81aa02448b615c4d5fc4f6544c53289dae9d2ec.tar.gz
There's an HTTP status code allocated for it in
<http://www.iana.org/assignments/http-status-codes>, so
return that instead of 400.
Diffstat (limited to 't')
-rwxr-xr-xt/t0002-parser-error.sh62
1 files changed, 61 insertions, 1 deletions
diff --git a/t/t0002-parser-error.sh b/t/t0002-parser-error.sh
index 9a3e7cf..f0df69d 100755
--- a/t/t0002-parser-error.sh
+++ b/t/t0002-parser-error.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 . ./test-lib.sh
-t_plan 5 "parser error test"
+t_plan 11 "parser error test"
 
 t_begin "setup and startup" && {
         unicorn_setup
@@ -24,6 +24,66 @@ t_begin "response should be a 400" && {
         grep -F 'HTTP/1.1 400 Bad Request' $tmp
 }
 
+t_begin "send a huge Request URI (REQUEST_PATH > (12 * 1024))" && {
+        rm -f $tmp
+        (
+                cat $fifo > $tmp &
+                set -e
+                trap 'wait && echo ok > $ok' EXIT
+                printf 'GET /'
+                for i in $(awk </dev/null 'BEGIN{for(i=0;i<1024;i++) print i}')
+                do
+                        printf '0123456789ab'
+                done
+                printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
+        ) | socat - TCP:$listen > $fifo || :
+        test xok = x$(cat $ok)
+}
+
+t_begin "response should be a 414" && {
+        grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
+}
+
+t_begin "send a huge Request URI (QUERY_STRING > (10 * 1024))" && {
+        rm -f $tmp
+        (
+                cat $fifo > $tmp &
+                set -e
+                trap 'wait && echo ok > $ok' EXIT
+                printf 'GET /hello-world?a'
+                for i in $(awk </dev/null 'BEGIN{for(i=0;i<1024;i++) print i}')
+                do
+                        printf '0123456789'
+                done
+                printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
+        ) | socat - TCP:$listen > $fifo || :
+        test xok = x$(cat $ok)
+}
+
+t_begin "response should be a 414" && {
+        grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
+}
+
+t_begin "send a huge Request URI (FRAGMENT > 1024)" && {
+        rm -f $tmp
+        (
+                cat $fifo > $tmp &
+                set -e
+                trap 'wait && echo ok > $ok' EXIT
+                printf 'GET /hello-world#a'
+                for i in $(awk </dev/null 'BEGIN{for(i=0;i<64;i++) print i}')
+                do
+                        printf '0123456789abcdef'
+                done
+                printf ' HTTP/1.1\r\nHost: example.com\r\n\r\n'
+        ) | socat - TCP:$listen > $fifo || :
+        test xok = x$(cat $ok)
+}
+
+t_begin "response should be a 414" && {
+        grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
+}
+
 t_begin "server stderr should be clean" && check_stderr
 
 t_begin "term signal sent" && kill $unicorn_pid