mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Add a test confirming push requests have no body
This commit is contained in:
parent
752297b153
commit
47ecfd7318
2 changed files with 14 additions and 0 deletions
|
@ -379,6 +379,8 @@ do(<<"stream_trailers">>, Req0, Opts) ->
|
||||||
end;
|
end;
|
||||||
do(<<"push">>, Req, Opts) ->
|
do(<<"push">>, Req, Opts) ->
|
||||||
case cowboy_req:binding(arg, Req) of
|
case cowboy_req:binding(arg, Req) of
|
||||||
|
<<"read_body">> ->
|
||||||
|
cowboy_req:push("/echo/read_body", #{}, Req, #{});
|
||||||
<<"method">> ->
|
<<"method">> ->
|
||||||
cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req,
|
cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req,
|
||||||
#{method => <<"HEAD">>});
|
#{method => <<"HEAD">>});
|
||||||
|
|
|
@ -4044,6 +4044,18 @@ reject_duplicate_content_length_header(Config) ->
|
||||||
% PUSH_PROMISE frame as a connection error (Section 5.4.1) of type
|
% PUSH_PROMISE frame as a connection error (Section 5.4.1) of type
|
||||||
% PROTOCOL_ERROR.
|
% PROTOCOL_ERROR.
|
||||||
|
|
||||||
|
push_has_no_request_body(Config) ->
|
||||||
|
doc("PUSH_PROMISE frames include the complete set of request headers "
|
||||||
|
"and the request can never include a body. (RFC7540 8.2.1)"),
|
||||||
|
ConnPid = gun_open(Config),
|
||||||
|
Ref = gun:get(ConnPid, "/resp/push/read_body"),
|
||||||
|
{push, PushRef, <<"GET">>, _, _} = gun:await(ConnPid, Ref),
|
||||||
|
{response, fin, 200, _} = gun:await(ConnPid, Ref),
|
||||||
|
%% We should not get a body in the pushed resource
|
||||||
|
%% since there was no body in the request.
|
||||||
|
{response, fin, 200, _} = gun:await(ConnPid, PushRef),
|
||||||
|
ok.
|
||||||
|
|
||||||
%% (RFC7540 8.2.1)
|
%% (RFC7540 8.2.1)
|
||||||
% The header fields in PUSH_PROMISE and any subsequent CONTINUATION
|
% The header fields in PUSH_PROMISE and any subsequent CONTINUATION
|
||||||
% frames MUST be a valid and complete set of request header fields
|
% frames MUST be a valid and complete set of request header fields
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue