diff options
-rw-r--r-- | examples/echo_post/src/toppage_handler.erl | 6 | ||||
-rw-r--r-- | src/cowboy_req.erl | 7 | ||||
-rw-r--r-- | test/http_handler_echo_body.erl | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/examples/echo_post/src/toppage_handler.erl b/examples/echo_post/src/toppage_handler.erl index 808ba8e..21e1dc6 100644 --- a/examples/echo_post/src/toppage_handler.erl +++ b/examples/echo_post/src/toppage_handler.erl @@ -12,9 +12,9 @@ init(_Transport, Req, []) -> handle(Req, State) -> {Method, Req2} = cowboy_req:method(Req), - {HasBody, Req3} = cowboy_req:has_body(Req2), - {ok, Req4} = maybe_echo(Method, HasBody, Req3), - {ok, Req4, State}. + HasBody = cowboy_req:has_body(Req2), + {ok, Req3} = maybe_echo(Method, HasBody, Req2), + {ok, Req3, State}. maybe_echo(<<"POST">>, true, Req) -> {ok, PostVals, Req2} = cowboy_req:body_qs(Req), diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index 4782eed..bf897a3 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -555,11 +555,10 @@ set_meta(Name, Value, Req=#http_req{meta=Meta}) -> %% Request Body API. %% @doc Return whether the request message has a body. --spec has_body(Req) -> {boolean(), Req} when Req::req(). +-spec has_body(cowboy_req:req()) -> boolean(). has_body(Req) -> - Has = lists:keymember(<<"content-length">>, 1, Req#http_req.headers) orelse - lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers), - {Has, Req}. + lists:keymember(<<"content-length">>, 1, Req#http_req.headers) orelse + lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers). %% @doc Return the request message body length, if known. %% diff --git a/test/http_handler_echo_body.erl b/test/http_handler_echo_body.erl index e4b1ee0..37c2072 100644 --- a/test/http_handler_echo_body.erl +++ b/test/http_handler_echo_body.erl @@ -8,8 +8,8 @@ init({_, http}, Req, _) -> {ok, Req, undefined}. handle(Req, State) -> - {true, Req1} = cowboy_req:has_body(Req), - {ok, Body, Req2} = cowboy_req:body(Req1), + true = cowboy_req:has_body(Req), + {ok, Body, Req2} = cowboy_req:body(Req), {Size, Req3} = cowboy_req:body_length(Req2), Size = byte_size(Body), {ok, Req4} = cowboy_req:reply(200, [], Body, Req3), |