diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-14 17:39:12 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-14 17:39:58 -0700 |
commit | 8b4a29032faac894f6702cc6160ef6366e739092 (patch) | |
tree | 93a60f3ac11c22464716416255c59ad2552bd258 | |
parent | 57a1ae94c3ac0948737744b651d59945c1ac3099 (diff) | |
download | rainbows-8b4a29032faac894f6702cc6160ef6366e739092.tar.gz |
We should try to send 400s back to the client if possible.
-rw-r--r-- | lib/rainbows/rev.rb | 4 | ||||
-rw-r--r-- | t/t4003-rev-parser-error.sh | 34 |
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/rainbows/rev.rb b/lib/rainbows/rev.rb index 8a575cd..abdc326 100644 --- a/lib/rainbows/rev.rb +++ b/lib/rainbows/rev.rb @@ -82,8 +82,6 @@ module Rainbows else @state = :close end - rescue Object => e - handle_error(e) end def on_write_complete @@ -137,6 +135,8 @@ module Rainbows when :trailers @hp.trailers(@env, @buf << data) and app_call end + rescue Object => e + handle_error(e) end end diff --git a/t/t4003-rev-parser-error.sh b/t/t4003-rev-parser-error.sh new file mode 100644 index 0000000..dff3e33 --- /dev/null +++ b/t/t4003-rev-parser-error.sh @@ -0,0 +1,34 @@ +#!/bin/sh +. ./test-lib.sh +require_rev + +eval $(unused_listen) +rtmpfiles unicorn_config pid r_err r_out tmp fifo ok +rm -f $fifo +mkfifo $fifo + +cat > $unicorn_config <<EOF +listen "$listen" +pid "$pid" +stderr_path "$r_err" +stdout_path "$r_out" +Rainbows! do + use :Rev +end +EOF + +rainbows -D t4000.ru -c $unicorn_config +wait_for_pid $pid + +( + printf 'GET / HTTP/1/1\r\nHost: example.com\r\n\r\n' + cat $fifo > $tmp & + wait + echo ok > $ok +) | socat - TCP:$listen > $fifo + +kill $(cat $pid) + +dbgcat tmp +grep -F 'HTTP/1.1 400 Bad Request' $tmp +! grep Error $r_err |