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

add guards on set_resp_body_fun for streamlen and streamfun

This commit is contained in:
Tristan Sloughter 2013-02-01 10:40:00 -06:00
parent 855e9652fa
commit 29c4508884

View file

@ -847,7 +847,7 @@ set_resp_body(Body, Req) ->
%% Cowboy will add a "Transfer-Encoding: identity" header to the
%% response.
-spec set_resp_body_fun(resp_body_fun(), Req) -> Req when Req::req().
set_resp_body_fun(StreamFun, Req) ->
set_resp_body_fun(StreamFun, Req) when is_function(StreamFun) ->
Req#http_req{resp_body=StreamFun}.
%% @doc Add a body function to the response.
@ -863,7 +863,7 @@ set_resp_body_fun(StreamFun, Req) ->
%% fewer bytes than declared the behaviour is undefined.
-spec set_resp_body_fun(non_neg_integer(), resp_body_fun(), Req)
-> Req when Req::req().
set_resp_body_fun(StreamLen, StreamFun, Req) ->
set_resp_body_fun(StreamLen, StreamFun, Req) when is_integer(StreamLen), is_function(StreamFun) ->
Req#http_req{resp_body={StreamLen, StreamFun}}.
%% @doc Return whether the given header has been set for the response.