aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-12-06 12:53:56 +0100
committerLoïc Hoguin <[email protected]>2011-12-06 12:53:56 +0100
commit3649b0ee0dd5ea9d64cc64fb0c16a20db21322f4 (patch)
treec87e1a3d0afb3a9309118c9fc4394aa2c7ba5ab2 /src/cowboy_http_req.erl
parent0201f7f2b2c8f1ce16fb7404b238e645c96685a7 (diff)
downloadcowboy-3649b0ee0dd5ea9d64cc64fb0c16a20db21322f4.tar.gz
cowboy-3649b0ee0dd5ea9d64cc64fb0c16a20db21322f4.tar.bz2
cowboy-3649b0ee0dd5ea9d64cc64fb0c16a20db21322f4.zip
Simplify the guards for cowboy_http_req:body/2
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 765d90b..d5ee3fa 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -341,12 +341,11 @@ body(Req) ->
-spec body(non_neg_integer(), #http_req{})
-> {ok, binary(), #http_req{}} | {error, atom()}.
body(Length, Req=#http_req{body_state=waiting, buffer=Buffer})
- when Length =< byte_size(Buffer) ->
+ when is_integer(Length) andalso Length =< byte_size(Buffer) ->
<< Body:Length/binary, Rest/bits >> = Buffer,
{ok, Body, Req#http_req{body_state=done, buffer=Rest}};
body(Length, Req=#http_req{socket=Socket, transport=Transport,
- body_state=waiting, buffer=Buffer})
- when is_integer(Length) andalso Length > byte_size(Buffer) ->
+ body_state=waiting, buffer=Buffer}) ->
case Transport:recv(Socket, Length - byte_size(Buffer), 5000) of
{ok, Body} -> {ok, << Buffer/binary, Body/binary >>,
Req#http_req{body_state=done, buffer= <<>>}};