mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Fix tests failing following Gun update to master
This commit is contained in:
parent
86c16fdccc
commit
36836594f8
3 changed files with 15 additions and 19 deletions
|
@ -73,10 +73,7 @@ do_body(Method, Path, Headers, Config) ->
|
||||||
do_body(Method, Path, Headers0, Body, Config) ->
|
do_body(Method, Path, Headers0, Body, Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Headers = [{<<"accept-encoding">>, <<"gzip">>}|Headers0],
|
Headers = [{<<"accept-encoding">>, <<"gzip">>}|Headers0],
|
||||||
Ref = case Body of
|
Ref = gun:request(ConnPid, Method, Path, Headers, Body),
|
||||||
<<>> -> gun:request(ConnPid, Method, Path, Headers);
|
|
||||||
_ -> gun:request(ConnPid, Method, Path, Headers, Body)
|
|
||||||
end,
|
|
||||||
{response, IsFin, 200, RespHeaders} = gun:await(ConnPid, Ref, 10000),
|
{response, IsFin, 200, RespHeaders} = gun:await(ConnPid, Ref, 10000),
|
||||||
{ok, RespBody} = case IsFin of
|
{ok, RespBody} = case IsFin of
|
||||||
nofin -> gun:await_body(ConnPid, Ref);
|
nofin -> gun:await_body(ConnPid, Ref);
|
||||||
|
@ -88,10 +85,7 @@ do_body(Method, Path, Headers0, Body, Config) ->
|
||||||
do_body_error(Method, Path, Headers0, Body, Config) ->
|
do_body_error(Method, Path, Headers0, Body, Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Headers = [{<<"accept-encoding">>, <<"gzip">>}|Headers0],
|
Headers = [{<<"accept-encoding">>, <<"gzip">>}|Headers0],
|
||||||
Ref = case Body of
|
Ref = gun:request(ConnPid, Method, Path, Headers, Body),
|
||||||
<<>> -> gun:request(ConnPid, Method, Path, Headers);
|
|
||||||
_ -> gun:request(ConnPid, Method, Path, Headers, Body)
|
|
||||||
end,
|
|
||||||
{response, _, Status, RespHeaders} = gun:await(ConnPid, Ref),
|
{response, _, Status, RespHeaders} = gun:await(ConnPid, Ref),
|
||||||
gun:close(ConnPid),
|
gun:close(ConnPid),
|
||||||
{Status, RespHeaders}.
|
{Status, RespHeaders}.
|
||||||
|
@ -215,7 +209,9 @@ headers(Config) ->
|
||||||
|
|
||||||
do_headers(Path, Config) ->
|
do_headers(Path, Config) ->
|
||||||
%% We always send accept-encoding with this test suite's requests.
|
%% We always send accept-encoding with this test suite's requests.
|
||||||
<<"#{<<\"accept-encoding\">> => <<\"gzip\">>,<<\"header\">> => <<\"value\">>", _/bits>>
|
<<"#{<<\"accept-encoding\">> => <<\"gzip\">>,"
|
||||||
|
"<<\"content-length\">> => <<\"0\">>,"
|
||||||
|
"<<\"header\">> => <<\"value\">>", _/bits>>
|
||||||
= do_get_body(Path, [{<<"header">>, "value"}], Config),
|
= do_get_body(Path, [{<<"header">>, "value"}], Config),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -468,7 +464,7 @@ read_body_period(Config) ->
|
||||||
doc("Read the request body for at most 1 second."),
|
doc("Read the request body for at most 1 second."),
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Body = <<0:8000000>>,
|
Body = <<0:8000000>>,
|
||||||
Ref = gun:request(ConnPid, "POST", "/opts/read_body/period", [
|
Ref = gun:headers(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.
|
%% The body is sent twice, first with nofin, then wait 2 seconds, then again with fin.
|
||||||
|
@ -482,7 +478,7 @@ read_body_period(Config) ->
|
||||||
%% We expect a crash.
|
%% We expect a crash.
|
||||||
do_read_body_timeout(Path, Body, Config) ->
|
do_read_body_timeout(Path, Body, Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:request(ConnPid, "POST", Path, [
|
Ref = gun:headers(ConnPid, "POST", Path, [
|
||||||
{<<"content-length">>, integer_to_binary(byte_size(Body))}
|
{<<"content-length">>, integer_to_binary(byte_size(Body))}
|
||||||
]),
|
]),
|
||||||
{response, _, 500, _} = gun:await(ConnPid, Ref),
|
{response, _, 500, _} = gun:await(ConnPid, Ref),
|
||||||
|
@ -538,7 +534,7 @@ read_urlencoded_body(Config) ->
|
||||||
%% We expect a crash.
|
%% We expect a crash.
|
||||||
do_read_urlencoded_body_too_large(Path, Body, Config) ->
|
do_read_urlencoded_body_too_large(Path, Body, Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:request(ConnPid, "POST", Path, [
|
Ref = gun:headers(ConnPid, "POST", Path, [
|
||||||
{<<"content-length">>, integer_to_binary(iolist_size(Body))}
|
{<<"content-length">>, integer_to_binary(iolist_size(Body))}
|
||||||
]),
|
]),
|
||||||
gun:data(ConnPid, Ref, fin, Body),
|
gun:data(ConnPid, Ref, fin, Body),
|
||||||
|
@ -548,7 +544,7 @@ do_read_urlencoded_body_too_large(Path, Body, Config) ->
|
||||||
%% We expect a crash.
|
%% We expect a crash.
|
||||||
do_read_urlencoded_body_too_long(Path, Body, Config) ->
|
do_read_urlencoded_body_too_long(Path, Body, Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:request(ConnPid, "POST", Path, [
|
Ref = gun:headers(ConnPid, "POST", Path, [
|
||||||
{<<"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),
|
||||||
|
@ -945,7 +941,7 @@ stream_body_content_length_nofin_error(Config) ->
|
||||||
case do_get_error("/resp/stream_body_content_length/nofin-error", Config) of
|
case do_get_error("/resp/stream_body_content_length/nofin-error", Config) of
|
||||||
{200, Headers, <<"Hello">>} ->
|
{200, Headers, <<"Hello">>} ->
|
||||||
{_, <<"gzip">>} = lists:keyfind(<<"content-encoding">>, 1, Headers);
|
{_, <<"gzip">>} = lists:keyfind(<<"content-encoding">>, 1, Headers);
|
||||||
{error, {closed, "The connection was lost."}} ->
|
{error, {stream_error, closed}} ->
|
||||||
ok;
|
ok;
|
||||||
{error, timeout} ->
|
{error, timeout} ->
|
||||||
ok
|
ok
|
||||||
|
|
|
@ -157,7 +157,7 @@ method_delete(Config) ->
|
||||||
% ConnPid = gun_open(Config),
|
% ConnPid = gun_open(Config),
|
||||||
% Ref = gun:request(ConnPid, <<"CONNECT">>, "localhost:8080", [
|
% Ref = gun:request(ConnPid, <<"CONNECT">>, "localhost:8080", [
|
||||||
% {<<"accept-encoding">>, <<"gzip">>}
|
% {<<"accept-encoding">>, <<"gzip">>}
|
||||||
% ]),
|
% ], <<>>),
|
||||||
% {response, fin, 501, _} = gun:await(ConnPid, Ref),
|
% {response, fin, 501, _} = gun:await(ConnPid, Ref),
|
||||||
% ok.
|
% ok.
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ method_trace(Config) ->
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:request(ConnPid, <<"TRACE">>, "/", [
|
Ref = gun:request(ConnPid, <<"TRACE">>, "/", [
|
||||||
{<<"accept-encoding">>, <<"gzip">>}
|
{<<"accept-encoding">>, <<"gzip">>}
|
||||||
]),
|
], <<>>),
|
||||||
{response, fin, 501, _} = gun:await(ConnPid, Ref),
|
{response, fin, 501, _} = gun:await(ConnPid, Ref),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ crash_in_init(Config) ->
|
||||||
%% Receive a 500 error response.
|
%% Receive a 500 error response.
|
||||||
case gun:await(ConnPid, Ref) of
|
case gun:await(ConnPid, Ref) of
|
||||||
{response, fin, 500, _} -> ok;
|
{response, fin, 500, _} -> ok;
|
||||||
{error, {stream_error, internal_error, _}} -> ok
|
{error, {stream_error, {stream_error, internal_error, _}}} -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
crash_in_data(Config) ->
|
crash_in_data(Config) ->
|
||||||
|
@ -123,7 +123,7 @@ crash_in_data(Config) ->
|
||||||
%% Receive a 500 error response.
|
%% Receive a 500 error response.
|
||||||
case gun:await(ConnPid, Ref) of
|
case gun:await(ConnPid, Ref) of
|
||||||
{response, fin, 500, _} -> ok;
|
{response, fin, 500, _} -> ok;
|
||||||
{error, {stream_error, internal_error, _}} -> ok
|
{error, {stream_error, {stream_error, internal_error, _}}} -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
crash_in_info(Config) ->
|
crash_in_info(Config) ->
|
||||||
|
@ -144,7 +144,7 @@ crash_in_info(Config) ->
|
||||||
%% Receive a 500 error response.
|
%% Receive a 500 error response.
|
||||||
case gun:await(ConnPid, Ref) of
|
case gun:await(ConnPid, Ref) of
|
||||||
{response, fin, 500, _} -> ok;
|
{response, fin, 500, _} -> ok;
|
||||||
{error, {stream_error, internal_error, _}} -> ok
|
{error, {stream_error, {stream_error, internal_error, _}}} -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
crash_in_terminate(Config) ->
|
crash_in_terminate(Config) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue