aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-02-05 18:06:00 +0100
committerLoïc Hoguin <[email protected]>2020-02-05 18:06:00 +0100
commit47ecfd73181dc888f01479069cb7e076352da9ca (patch)
tree1f7160d53c9e2993aa4723b0cdf84855b96868dc
parent752297b1539b4f74c9329c873f78485a52b5b8bd (diff)
downloadcowboy-47ecfd73181dc888f01479069cb7e076352da9ca.tar.gz
cowboy-47ecfd73181dc888f01479069cb7e076352da9ca.tar.bz2
cowboy-47ecfd73181dc888f01479069cb7e076352da9ca.zip
Add a test confirming push requests have no body
-rw-r--r--test/handlers/resp_h.erl2
-rw-r--r--test/rfc7540_SUITE.erl12
2 files changed, 14 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index cf21536..d43152e 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -379,6 +379,8 @@ do(<<"stream_trailers">>, Req0, Opts) ->
end;
do(<<"push">>, Req, Opts) ->
case cowboy_req:binding(arg, Req) of
+ <<"read_body">> ->
+ cowboy_req:push("/echo/read_body", #{}, Req, #{});
<<"method">> ->
cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req,
#{method => <<"HEAD">>});
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 17ac319..aec0aa1 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -4044,6 +4044,18 @@ reject_duplicate_content_length_header(Config) ->
% PUSH_PROMISE frame as a connection error (Section 5.4.1) of type
% 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)
% The header fields in PUSH_PROMISE and any subsequent CONTINUATION
% frames MUST be a valid and complete set of request header fields