mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Remove/convert tests about request body from old_http_SUITE
This commit is contained in:
parent
9ee8904cc6
commit
3d35319112
2 changed files with 16 additions and 28 deletions
|
@ -245,25 +245,6 @@ check_status(Config) ->
|
||||||
{Ret, URL}
|
{Ret, URL}
|
||||||
end || {Status, URL} <- Tests].
|
end || {Status, URL} <- Tests].
|
||||||
|
|
||||||
%% Check if sending requests whose size is around the MTU breaks something.
|
|
||||||
echo_body(Config) ->
|
|
||||||
MTU = ct_helper:get_loopback_mtu(),
|
|
||||||
_ = [begin
|
|
||||||
Body = list_to_binary(lists:duplicate(Size, $a)),
|
|
||||||
ConnPid = gun_open(Config),
|
|
||||||
Ref = gun:post(ConnPid, "/echo/body", [], Body),
|
|
||||||
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
|
|
||||||
{ok, Body} = gun:await_body(ConnPid, Ref)
|
|
||||||
end || Size <- lists:seq(MTU - 500, MTU)],
|
|
||||||
ok.
|
|
||||||
|
|
||||||
%% Check if sending request whose size is bigger than 1000000 bytes causes 413
|
|
||||||
echo_body_max_length(Config) ->
|
|
||||||
ConnPid = gun_open(Config),
|
|
||||||
Ref = gun:post(ConnPid, "/echo/body", [], << 0:10000000/unit:8 >>),
|
|
||||||
{response, nofin, 413, _} = gun:await(ConnPid, Ref),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
error_init_after_reply(Config) ->
|
error_init_after_reply(Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:get(ConnPid, "/handler_errors?case=init_after_reply"),
|
Ref = gun:get(ConnPid, "/handler_errors?case=init_after_reply"),
|
||||||
|
|
|
@ -432,28 +432,35 @@ read_body(Config) ->
|
||||||
<<"hello world!">> = do_body("POST", "/read_body", [], "hello world!", Config),
|
<<"hello world!">> = do_body("POST", "/read_body", [], "hello world!", Config),
|
||||||
%% We expect to have read *at least* 1000 bytes.
|
%% We expect to have read *at least* 1000 bytes.
|
||||||
<<0:8000, _/bits>> = do_body("POST", "/opts/read_body/length", [], <<0:8000000>>, Config),
|
<<0:8000, _/bits>> = do_body("POST", "/opts/read_body/length", [], <<0:8000000>>, Config),
|
||||||
%% We read any length for at most 1 second.
|
|
||||||
%%
|
|
||||||
%% The body is sent twice, first with nofin, then wait 2 seconds, then again with fin.
|
|
||||||
<<0:8000000>> = do_read_body_period("/opts/read_body/period", <<0:8000000>>, Config),
|
|
||||||
%% The timeout value is set too low on purpose to ensure a crash occurs.
|
%% The timeout value is set too low on purpose to ensure a crash occurs.
|
||||||
ok = do_read_body_timeout("/opts/read_body/timeout", <<0:8000000>>, Config),
|
ok = do_read_body_timeout("/opts/read_body/timeout", <<0:8000000>>, Config),
|
||||||
%% 10MB body larger than default length.
|
%% 10MB body larger than default length.
|
||||||
<<0:80000000>> = do_body("POST", "/full/read_body", [], <<0:80000000>>, Config),
|
<<0:80000000>> = do_body("POST", "/full/read_body", [], <<0:80000000>>, Config),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
do_read_body_period(Path, Body, Config) ->
|
read_body_mtu(Config) ->
|
||||||
|
doc("Request body whose sizes are around the MTU."),
|
||||||
|
MTU = ct_helper:get_loopback_mtu(),
|
||||||
|
_ = [begin
|
||||||
|
Body = <<0:Size/unit:8>>,
|
||||||
|
Body = do_body("POST", "/full/read_body", [], Body, Config)
|
||||||
|
end || Size <- lists:seq(MTU - 10, MTU + 10)],
|
||||||
|
ok.
|
||||||
|
|
||||||
|
read_body_period(Config) ->
|
||||||
|
doc("Read the request body for at most 1 second."),
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:request(ConnPid, "POST", Path, [
|
Body = <<0:8000000>>,
|
||||||
|
Ref = gun:request(ConnPid, "POST", "/opts/read_body/period", [
|
||||||
{<<"content-length">>, integer_to_binary(byte_size(Body) * 2)}
|
{<<"content-length">>, integer_to_binary(byte_size(Body) * 2)}
|
||||||
]),
|
]),
|
||||||
|
%% The body is sent twice, first with nofin, then wait 2 seconds, then again with fin.
|
||||||
gun:data(ConnPid, Ref, nofin, Body),
|
gun:data(ConnPid, Ref, nofin, Body),
|
||||||
timer:sleep(2000),
|
timer:sleep(2000),
|
||||||
gun:data(ConnPid, Ref, fin, Body),
|
gun:data(ConnPid, Ref, fin, Body),
|
||||||
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
|
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
|
||||||
{ok, RespBody} = gun:await_body(ConnPid, Ref),
|
{ok, Body} = gun:await_body(ConnPid, Ref),
|
||||||
gun:close(ConnPid),
|
gun:close(ConnPid).
|
||||||
RespBody.
|
|
||||||
|
|
||||||
%% We expect a crash.
|
%% We expect a crash.
|
||||||
do_read_body_timeout(Path, Body, Config) ->
|
do_read_body_timeout(Path, Body, Config) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue