aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_handler.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-04-12 14:16:59 +0200
committerLoïc Hoguin <[email protected]>2013-04-12 14:32:37 +0200
commit2aabc73045daa1c06d73c76ffc442ee7ebe38d14 (patch)
tree507f2cef335e141227a02a36c933d6567c87b95d /src/cowboy_handler.erl
parent1eb2bda3041ccc87690d74087011074db6699147 (diff)
downloadcowboy-2aabc73045daa1c06d73c76ffc442ee7ebe38d14.tar.gz
cowboy-2aabc73045daa1c06d73c76ffc442ee7ebe38d14.tar.bz2
cowboy-2aabc73045daa1c06d73c76ffc442ee7ebe38d14.zip
Ensure we can fetch the body in the info/3 function of loop handlers
Diffstat (limited to 'src/cowboy_handler.erl')
-rw-r--r--src/cowboy_handler.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/cowboy_handler.erl b/src/cowboy_handler.erl
index 7aaf9ae..7d00524 100644
--- a/src/cowboy_handler.erl
+++ b/src/cowboy_handler.erl
@@ -214,7 +214,18 @@ handler_loop(Req, State=#state{loop_buffer_size=NbBytes,
{timeout, OlderTRef, ?MODULE} when is_reference(OlderTRef) ->
handler_before_loop(Req, State, Handler, HandlerState);
Message ->
- handler_call(Req, State, Handler, HandlerState, Message)
+ %% We set the socket back to {active, false} mode in case
+ %% the handler is going to call recv. We also flush any
+ %% data received after that and put it into the buffer.
+ %% We do not check the size here, if data keeps coming
+ %% we'll error out on the next packet received.
+ Transport:setopts(Socket, [{active, false}]),
+ Req2 = receive {OK, Socket, Data} ->
+ cowboy_req:append_buffer(Data, Req)
+ after 0 ->
+ Req
+ end,
+ handler_call(Req2, State, Handler, HandlerState, Message)
end.
-spec handler_call(Req, #state{}, module(), any(), any())