aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-07-12 12:09:43 +0200
committerLoïc Hoguin <[email protected]>2014-07-12 12:09:43 +0200
commit97a3108576c6a9d64c03e1455654dba88367992a (patch)
treec9701a8ba567e777509e0fd3508ed6f0bc6b5ea0 /test
parent20f598f3736cdaab8fd0e9de09f16d18d1dc97f8 (diff)
downloadcowboy-97a3108576c6a9d64c03e1455654dba88367992a.tar.gz
cowboy-97a3108576c6a9d64c03e1455654dba88367992a.tar.bz2
cowboy-97a3108576c6a9d64c03e1455654dba88367992a.zip
Reply with 400 on header parsing crash
This is a first step to improve the HTTP status codes returned by Cowboy on crashes. We will tweak it over time. Also fixes a small bug where two replies may have been sent when using loop handlers under rare conditions.
Diffstat (limited to 'test')
-rw-r--r--test/handlers/input_crash_h.erl10
-rw-r--r--test/http_SUITE.erl2
2 files changed, 12 insertions, 0 deletions
diff --git a/test/handlers/input_crash_h.erl b/test/handlers/input_crash_h.erl
new file mode 100644
index 0000000..668d053
--- /dev/null
+++ b/test/handlers/input_crash_h.erl
@@ -0,0 +1,10 @@
+%% This module crashes on request input data
+%% depending on the given option.
+
+-module(input_crash_h).
+
+-export([init/3]).
+
+init(_, Req, content_length) ->
+ cowboy_error_h:ignore(cow_http_hd, number, 2),
+ cowboy_req:parse_header(<<"content-length">>, Req).
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 5888421..e5a9256 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -193,6 +193,7 @@ init_dispatch(Config) ->
{"/multipart/large", http_multipart_stream, []},
{"/echo/body", http_echo_body, []},
{"/echo/body_qs", http_body_qs, []},
+ {"/crash/content-length", input_crash_h, content_length},
{"/param_all", rest_param_all, []},
{"/bad_accept", rest_simple_resource, []},
{"/bad_content_type", rest_patch_resource, []},
@@ -274,6 +275,7 @@ The document has moved
{400, "GET / HTTP/1.1\r\nHost: ninenines.eu\r\n\r\n"},
{400, "GET http://proxy/ HTTP/1.1\r\n\r\n"},
{400, "GET / HTTP/1.1\r\nHost: localhost:bad_port\r\n\r\n"},
+ {400, ["POST /crash/content-length HTTP/1.1\r\nHost: localhost\r\nContent-Length: 5000,5000\r\n\r\n", Huge]},
{505, ResponsePacket},
{408, "GET / HTTP/1.1\r\n"},
{408, "GET / HTTP/1.1\r\nHost: localhost"},