aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-12-06 12:22:36 +0100
committerLoïc Hoguin <[email protected]>2011-12-06 12:22:36 +0100
commit0201f7f2b2c8f1ce16fb7404b238e645c96685a7 (patch)
tree2edc8478c56342baaaf31a9d74f3ad16b8304a42 /test/http_SUITE.erl
parentaab1587a4b3d8f0c3d92a2083227527d51109980 (diff)
downloadcowboy-0201f7f2b2c8f1ce16fb7404b238e645c96685a7.tar.gz
cowboy-0201f7f2b2c8f1ce16fb7404b238e645c96685a7.tar.bz2
cowboy-0201f7f2b2c8f1ce16fb7404b238e645c96685a7.zip
cowboy_http_protocol shouldn't crash if the client sends HTTP responses
It was replying back the correct error, but with a crash message in the console. This patch prevents it from crashing. Fixes issue #94 reported by oribrost.
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index eb0bf54..2db6ff4 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -22,7 +22,7 @@
keepalive_nl/1, nc_rand/1, nc_zero/1, pipeline/1, raw/1,
ws0/1, ws8/1, ws8_single_bytes/1, ws8_init_shutdown/1,
ws13/1, ws_timeout_hibernate/1, set_resp_header/1,
- set_resp_overwrite/1, set_resp_body/1]). %% http.
+ set_resp_overwrite/1, set_resp_body/1, response_as_req/1]). %% http.
-export([http_200/1, http_404/1]). %% http and https.
-export([http_10_hostless/1]). %% misc.
-export([rest_simple/1]). %% rest.
@@ -37,8 +37,8 @@ groups() ->
[{http, [], [chunked_response, headers_dupe, headers_huge,
keepalive_nl, nc_rand, nc_zero, pipeline, raw,
ws0, ws8, ws8_single_bytes, ws8_init_shutdown, ws13,
- ws_timeout_hibernate, set_resp_header,
- set_resp_overwrite, set_resp_body] ++ BaseTests},
+ ws_timeout_hibernate, set_resp_header, set_resp_overwrite,
+ set_resp_body, response_as_req] ++ BaseTests},
{https, [], BaseTests},
{misc, [], [http_10_hostless]},
{rest, [], [rest_simple]}].
@@ -526,6 +526,27 @@ set_resp_body(Config) ->
{_Start, _Length} = binary:match(Data, <<"\r\n\r\n"
"A flameless dance does not equal a cycle">>).
+response_as_req(Config) ->
+ Packet =
+"HTTP/1.0 302 Found
+Location: http://www.google.co.il/
+Cache-Control: private
+Content-Type: text/html; charset=UTF-8
+Set-Cookie: PREF=ID=568f67013d4a7afa:FF=0:TM=1323014101:LM=1323014101:S=XqctDWC65MzKT0zC; expires=Tue, 03-Dec-2013 15:55:01 GMT; path=/; domain=.google.com
+Date: Sun, 04 Dec 2011 15:55:01 GMT
+Server: gws
+Content-Length: 221
+X-XSS-Protection: 1; mode=block
+X-Frame-Options: SAMEORIGIN
+
+<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">
+<TITLE>302 Moved</TITLE></HEAD><BODY>
+<H1>302 Moved</H1>
+The document has moved
+<A HREF=\"http://www.google.co.il/\">here</A>.
+</BODY></HTML>",
+ {Packet, 400} = raw_req(Packet, Config).
+
%% http and https.
build_url(Path, Config) ->