diff options
author | Loïc Hoguin <[email protected]> | 2013-03-06 17:50:53 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-03-06 17:50:53 +0100 |
commit | fddd4a77fb6497a3052137683b3d9c4ca487ac78 (patch) | |
tree | f55c70b2eb502d39735b6d289344a0cb3b03b0aa /test/http_SUITE.erl | |
parent | a930f4ab267064a6316e8914355a4ab4ebd8990c (diff) | |
parent | 84d7671e91bb2dee2081172dbf651860134ae75e (diff) | |
download | cowboy-fddd4a77fb6497a3052137683b3d9c4ca487ac78.tar.gz cowboy-fddd4a77fb6497a3052137683b3d9c4ca487ac78.tar.bz2 cowboy-fddd4a77fb6497a3052137683b3d9c4ca487ac78.zip |
Merge branch 'check-body-length' of git://github.com/rambocoder/cowboy
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r-- | test/http_SUITE.erl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index bd76f00..911efb8 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -30,6 +30,9 @@ -export([check_status/1]). -export([chunked_response/1]). -export([echo_body/1]). +-export([echo_body_max_length/1]). +-export([echo_body_qs/1]). +-export([echo_body_qs_max_length/1]). -export([error_chain_handle_after_reply/1]). -export([error_chain_handle_before_reply/1]). -export([error_handle_after_reply/1]). @@ -102,6 +105,9 @@ groups() -> check_status, chunked_response, echo_body, + echo_body_max_length, + echo_body_qs, + echo_body_qs_max_length, error_chain_handle_after_reply, error_chain_handle_before_reply, error_handle_after_reply, @@ -348,6 +354,7 @@ init_dispatch(Config) -> {file, <<"test_file.css">>}]}, {"/multipart", http_handler_multipart, []}, {"/echo/body", http_handler_echo_body, []}, + {"/echo/body_qs", http_handler_body_qs, []}, {"/param_all", rest_param_all, []}, {"/bad_accept", rest_simple_resource, []}, {"/simple", rest_simple_resource, []}, @@ -533,6 +540,41 @@ echo_body(Config) -> {ok, Body, _} = cowboy_client:response_body(Client3) end || Size <- lists:seq(MTU - 500, MTU)]. +%% Check if sending request whose size is bigger than 1000000 bytes causes 413 +echo_body_max_length(Config) -> + Client = ?config(client, Config), + Body = <<$a:8000008>>, + {ok, Client2} = cowboy_client:request(<<"POST">>, + build_url("/echo/body", Config), + [{<<"connection">>, <<"close">>}], + Body, Client), + {ok, 413, _, _} = cowboy_client:response(Client2). + +% check if body_qs echo's back results +echo_body_qs(Config) -> + Client = ?config(client, Config), + Body = <<"echo=67890">>, + {ok, Client2} = cowboy_client:request(<<"POST">>, + build_url("/echo/body_qs", Config), + [{<<"connection">>, <<"close">>}], + Body, Client), + {ok, 200, _, Client3} = cowboy_client:response(Client2), + {ok, <<"67890">>, _} = cowboy_client:response_body(Client3). + +%% Check if sending request whose size is bigger 16000 bytes causes 413 +echo_body_qs_max_length(Config) -> + Client = ?config(client, Config), + DefaultMaxBodyQsLength = 16000, + % subtract "echo=" minus 1 byte from max to hit the limit + Bits = (DefaultMaxBodyQsLength - 4) * 8, + AppendedBody = <<$a:Bits>>, + Body = <<"echo=", AppendedBody/binary>>, + {ok, Client2} = cowboy_client:request(<<"POST">>, + build_url("/echo/body_qs", Config), + [{<<"connection">>, <<"close">>}], + Body, Client), + {ok, 413, _, _} = cowboy_client:response(Client2). + error_chain_handle_after_reply(Config) -> Client = ?config(client, Config), {ok, Client2} = cowboy_client:request(<<"GET">>, |