Browse Source

Merge branch 'master' of git://github.com/tsloughter/cowboy

Loïc Hoguin 12 years ago
parent
commit
4e71cd0f14
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/cowboy_req.erl

+ 3 - 2
src/cowboy_req.erl

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