0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Make req_SUITE:read*_body_urlencoded_too_long tests reliable

This commit is contained in:
Loïc Hoguin 2020-04-02 15:46:38 +02:00
parent 909c8a4b4d
commit 962d715ad4
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -577,7 +577,7 @@ do_read_urlencoded_body_too_large(Path, Body, Config) ->
read_urlencoded_body_too_long(Config) -> read_urlencoded_body_too_long(Config) ->
doc("application/x-www-form-urlencoded request body sent too slow. " doc("application/x-www-form-urlencoded request body sent too slow. "
"The body is sent twice with 2s wait in-between. It is read by the handler " "The body is simply not being sent fully. It is read by the handler "
"for at most 1 second. A crash occurs because we don't have the full body."), "for at most 1 second. A crash occurs because we don't have the full body."),
do_read_urlencoded_body_too_long("/crash/read_urlencoded_body/period", <<"abc">>, Config). do_read_urlencoded_body_too_long("/crash/read_urlencoded_body/period", <<"abc">>, Config).
@ -588,8 +588,6 @@ do_read_urlencoded_body_too_long(Path, Body, Config) ->
{<<"content-length">>, integer_to_binary(byte_size(Body) * 2)} {<<"content-length">>, integer_to_binary(byte_size(Body) * 2)}
]), ]),
gun:data(ConnPid, Ref, nofin, Body), gun:data(ConnPid, Ref, nofin, Body),
timer:sleep(2000),
gun:data(ConnPid, Ref, fin, Body),
{response, _, 408, RespHeaders} = gun:await(ConnPid, Ref, infinity), {response, _, 408, RespHeaders} = gun:await(ConnPid, Ref, infinity),
_ = case config(protocol, Config) of _ = case config(protocol, Config) of
http -> http ->
@ -626,7 +624,7 @@ read_and_match_urlencoded_body_too_large(Config) ->
read_and_match_urlencoded_body_too_long(Config) -> read_and_match_urlencoded_body_too_long(Config) ->
doc("Read and match an application/x-www-form-urlencoded request body sent too slow. " doc("Read and match an application/x-www-form-urlencoded request body sent too slow. "
"The body is sent twice with 2s wait in-between. It is read by the handler " "The body is simply not being sent fully. It is read by the handler "
"for at most 1 second. A crash occurs because we don't have the full body."), "for at most 1 second. A crash occurs because we don't have the full body."),
do_read_urlencoded_body_too_long( do_read_urlencoded_body_too_long(
"/crash/read_and_match_urlencoded_body/period", <<"abc">>, Config). "/crash/read_and_match_urlencoded_body/period", <<"abc">>, Config).