Permalink
Browse files

Add a test checking requests with size around the MTU

  • Loading branch information...
1 parent 5ffeb9e commit 90bae59307394a0cb2642db504da53f234cf6b42 Loïc Hoguin committed May 5, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/http_SUITE.erl
View
@@ -29,6 +29,7 @@
-export([check_raw_status/1]).
-export([check_status/1]).
-export([chunked_response/1]).
+-export([echo_body/1]).
-export([error_chain_handle_after_reply/1]).
-export([error_chain_handle_before_reply/1]).
-export([error_handle_after_reply/1]).
@@ -74,6 +75,7 @@ groups() ->
check_raw_status,
check_status,
chunked_response,
+ echo_body,
error_chain_handle_after_reply,
error_chain_handle_before_reply,
error_handle_after_reply,
@@ -394,6 +396,20 @@ chunked_response(Config) ->
{ok, {{"HTTP/1.1", 200, "OK"}, _, "chunked_handler\r\nworks fine!"}}
= httpc:request(binary_to_list(build_url("/chunked_response", Config))).
+%% Check if sending requests whose size is around the MTU breaks something.
+echo_body(Config) ->
+ Client = ?config(client, Config),
+ {ok, [{mtu, MTU}]} = inet:ifget("lo", [mtu]),
+ [begin
+ Body = list_to_binary(lists:duplicate(Size, $a)),
+ {ok, Client2} = cowboy_client:request(<<"POST">>,
+ build_url("/echo/body", Config),
+ [{<<"connection">>, <<"close">>}],
+ Body, Client),
+ {ok, 200, _, Client3} = cowboy_client:response(Client2),
+ {ok, Body, _} = cowboy_client:response_body(Client3)
+ end || Size <- lists:seq(MTU - 500, MTU)].
+
error_chain_handle_after_reply(Config) ->
Client = ?config(client, Config),
{ok, Client2} = cowboy_client:request(<<"GET">>,

0 comments on commit 90bae59

Please sign in to comment.