diff options
author | Loïc Hoguin <[email protected]> | 2011-03-21 21:28:24 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-03-21 22:08:27 +0100 |
commit | 7cacb88fecc2d64609168167303aaca00181ee53 (patch) | |
tree | 6b473fbec2429475e8489756bdd097789614f351 /src/cowboy_http_protocol.erl | |
parent | e9781e77f15a8bfa339d53cf6207a2453cb4c322 (diff) | |
download | cowboy-7cacb88fecc2d64609168167303aaca00181ee53.tar.gz cowboy-7cacb88fecc2d64609168167303aaca00181ee53.tar.bz2 cowboy-7cacb88fecc2d64609168167303aaca00181ee53.zip |
Introduce cowboy_http_req:body/1 to read the full request body.
Diffstat (limited to 'src/cowboy_http_protocol.erl')
-rw-r--r-- | src/cowboy_http_protocol.erl | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index 7209be4..34f0c0d 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -167,17 +167,8 @@ handler_terminate(HandlerState, Req, State=#state{handler={Handler, _Opts}}) -> ensure_body_processed(#http_req{body_state=done}) -> ok; ensure_body_processed(Req=#http_req{body_state=waiting}) -> - {Length, Req2} = cowboy_http_req:header('Content-Length', Req), - case Length of - "" -> ok; - _Any -> - Length2 = list_to_integer(Length), - skip_body(Length2, Req2) - end. - --spec skip_body(Length::non_neg_integer(), Req::#http_req{}) -> ok | close. -skip_body(Length, Req) -> - case cowboy_http_req:body(Length, Req) of + case cowboy_http_req:body(Req) of + {error, badarg} -> ok; %% No body. {error, _Reason} -> close; _Any -> ok end. |