aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_handler.erl
diff options
context:
space:
mode:
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())