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

Add specs for the cowboy_req:push/3,4 functions

This commit is contained in:
Loïc Hoguin 2016-08-10 17:52:44 +02:00
parent 83aa3f1b9c
commit 5fa5ba8ca4

View file

@ -94,6 +94,9 @@
| {sendfile, non_neg_integer(), pos_integer(), file:name_all()}.
-export_type([resp_body/0]).
-type push_opts() :: map(). %% @todo
-export_type([push_opts/0]).
-type req() :: map(). %% @todo #{
% ref := ranch:ref(),
% pid := pid(),
@ -649,12 +652,14 @@ stream_body(Data, IsFin, #{pid := Pid, streamid := StreamID, has_sent_resp := he
Pid ! {{Pid, StreamID}, {data, IsFin, Data}},
ok.
-spec push(binary(), cowboy:http_headers(), req()) -> ok.
push(Path, Headers, Req) ->
push(Path, Headers, Req, #{}).
%% @todo Optimization: don't send anything at all for HTTP/1.0 and HTTP/1.1.
%% @todo Path, Headers, Opts, everything should be in proper binary,
%% or normalized when creating the Req object.
-spec push(binary(), cowboy:http_headers(), req(), push_opts()) -> ok.
push(Path, Headers, #{pid := Pid, streamid := StreamID,
scheme := Scheme0, host := Host0, port := Port0}, Opts) ->
Method = maps:get(method, Opts, <<"GET">>),