mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Fix the reading of the localhost MTU in the HTTP tests
Sometimes the localhost interface has a different name from "lo", this fix adds a helper function to read the MTU value when the interface name starts with "lo".
This commit is contained in:
parent
1fc69977da
commit
fdd67b72a3
1 changed files with 10 additions and 1 deletions
|
@ -420,6 +420,15 @@ body_to_chunks(ChunkSize, Body, Acc) ->
|
|||
body_to_chunks(ChunkSize, Rest,
|
||||
[<< ChunkSizeBin/binary, "\r\n", Chunk/binary, "\r\n" >>|Acc]).
|
||||
|
||||
get_mtu() ->
|
||||
{ok, Interfaces} = inet:getiflist(),
|
||||
[LocalInterface | _] = lists:filter(fun
|
||||
("lo" ++ _) -> true;
|
||||
(_) -> false
|
||||
end, Interfaces),
|
||||
{ok, [{mtu, MTU}]} = inet:ifget(LocalInterface, [mtu]),
|
||||
MTU.
|
||||
|
||||
%% Tests.
|
||||
|
||||
check_raw_status(Config) ->
|
||||
|
@ -517,7 +526,7 @@ 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]),
|
||||
MTU = get_mtu(),
|
||||
_ = [begin
|
||||
Body = list_to_binary(lists:duplicate(Size, $a)),
|
||||
{ok, Client2} = cowboy_client:request(<<"POST">>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue