aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2011-11-08 00:51:49 +0100
committerLoïc Hoguin <[email protected]>2012-01-23 07:20:35 +0100
commit528507c7decb2bf2fcbb55a47256011c2ce4bd4b (patch)
tree14966540ecf17499d1d3e161c5690f5de4fbbf0d /test/http_SUITE.erl
parenta5b47fda8de7972c9affb4f4d1320fb666c67a92 (diff)
downloadcowboy-528507c7decb2bf2fcbb55a47256011c2ce4bd4b.tar.gz
cowboy-528507c7decb2bf2fcbb55a47256011c2ce4bd4b.tar.bz2
cowboy-528507c7decb2bf2fcbb55a47256011c2ce4bd4b.zip
Add multipart support
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index bfccd3b..21bac1f 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -1,4 +1,5 @@
%% Copyright (c) 2011, Loïc Hoguin <[email protected]>
+%% Copyright (c) 2011, Anthony Ramine <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
@@ -19,7 +20,7 @@
-export([all/0, groups/0, init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2]). %% ct.
-export([chunked_response/1, headers_dupe/1, headers_huge/1,
- keepalive_nl/1, nc_rand/1, nc_zero/1, pipeline/1, raw/1,
+ keepalive_nl/1, multipart/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]). %% http.
-export([http_200/1, http_404/1]). %% http and https.
@@ -35,7 +36,7 @@ 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] ++ BaseTests},
+ ws_timeout_hibernate, multipart] ++ BaseTests},
{https, [], BaseTests}, {misc, [], [http_10_hostless]}].
init_per_suite(Config) ->
@@ -100,6 +101,7 @@ init_http_dispatch() ->
{[<<"long_polling">>], http_handler_long_polling, []},
{[<<"headers">>, <<"dupe">>], http_handler,
[{headers, [{<<"Connection">>, <<"close">>}]}]},
+ {[<<"multipart">>], http_handler_multipart, []},
{[], http_handler, []}
]}
].
@@ -148,6 +150,24 @@ keepalive_nl_loop(Socket, N) ->
ok = gen_tcp:send(Socket, "\r\n"), %% extra nl
keepalive_nl_loop(Socket, N - 1).
+multipart(Config) ->
+ Url = build_url("/multipart", Config),
+ Body = <<
+ "This is a preamble."
+ "\r\n--OHai\r\nX-Name:answer\r\n\r\n42"
+ "\r\n--OHai\r\nServer:Cowboy\r\n\r\nIt rocks!\r\n"
+ "\r\n--OHai--"
+ "This is an epiloque."
+ >>,
+ Request = {Url, [], "multipart/x-makes-no-sense; boundary=OHai", Body},
+ {ok, {{"HTTP/1.1", 200, "OK"}, _Headers, Response}} =
+ httpc:request(post, Request, [], [{body_format, binary}]),
+ Parts = binary_to_term(Response),
+ Parts = [
+ {[{<<"X-Name">>, <<"answer">>}], <<"42">>},
+ {[{'Server', <<"Cowboy">>}], <<"It rocks!\r\n">>}
+ ].
+
nc_rand(Config) ->
nc_reqs(Config, "/dev/urandom").