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

Handle a test case sometimes sending a response too fast

This commit is contained in:
Loïc Hoguin 2018-11-20 11:28:46 +01:00
parent ff674fe6e8
commit 386df43ea4
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -159,16 +159,18 @@ set_options_chunked_false(Config) ->
Request = "GET /set_options/chunked_false HTTP/1.1\r\nhost: localhost\r\n\r\n", Request = "GET /set_options/chunked_false HTTP/1.1\r\nhost: localhost\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]), Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request), ok = raw_send(Client, Request),
_ = case catch raw_recv_head(Client) of Rest = case catch raw_recv_head(Client) of
{'EXIT', _} -> error(closed); {'EXIT', _} -> error(closed);
Data -> Data ->
%% Cowboy always advertises itself as HTTP/1.1. %% Cowboy always advertises itself as HTTP/1.1.
{'HTTP/1.1', 200, _, Rest} = cow_http:parse_status_line(Data), {'HTTP/1.1', 200, _, Rest0} = cow_http:parse_status_line(Data),
{Headers, <<>>} = cow_http:parse_headers(Rest), {Headers, Rest1} = cow_http:parse_headers(Rest0),
false = lists:keyfind(<<"content-length">>, 1, Headers), false = lists:keyfind(<<"content-length">>, 1, Headers),
false = lists:keyfind(<<"transfer-encoding">>, 1, Headers) false = lists:keyfind(<<"transfer-encoding">>, 1, Headers),
Rest1
end, end,
raw_expect_recv(Client, <<0:8000000>>), Bits = 8000000 - bit_size(Rest),
raw_expect_recv(Client, <<0:Bits>>),
{error, closed} = raw_recv(Client, 1, 1000) {error, closed} = raw_recv(Client, 1, 1000)
after after
cowboy:stop_listener(?FUNCTION_NAME) cowboy:stop_listener(?FUNCTION_NAME)