aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-02-11 09:03:13 +0100
committerLoïc Hoguin <[email protected]>2013-02-11 09:03:13 +0100
commit40b8d0befcd8b310a7a48e07df7d629153903cca (patch)
treeedd79574d4a9f6f01fbafe9295814dccd9528e52 /src/cowboy_req.erl
parent65ed13d2da2e6bab65fcde7db2e46060c33be71f (diff)
downloadcowboy-40b8d0befcd8b310a7a48e07df7d629153903cca.tar.gz
cowboy-40b8d0befcd8b310a7a48e07df7d629153903cca.tar.bz2
cowboy-40b8d0befcd8b310a7a48e07df7d629153903cca.zip
Better handle socket closing with loop handlers
We now read from the socket to be able to detect errors or TCP close events, and buffer the data if any. Once the data receive goes over a certain limit, which defaults to 5000 bytes, we simply close the connection with an {error, overflow} reason.
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index c807a75..d416916 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -104,6 +104,7 @@
-export([ensure_response/2]).
%% Private setter/getter API.
+-export([append_buffer/2]).
-export([get/2]).
-export([set/2]).
-export([set_bindings/4]).
@@ -1066,6 +1067,11 @@ ensure_response(#http_req{socket=Socket, transport=Transport,
%% Private setter/getter API.
%% @private
+-spec append_buffer(binary(), Req) -> Req when Req::req().
+append_buffer(Suffix, Req=#http_req{buffer=Buffer}) ->
+ Req#http_req{buffer= << Buffer/binary, Suffix/binary >>}.
+
+%% @private
-spec get(atom(), req()) -> any(); ([atom()], req()) -> any().
get(List, Req) when is_list(List) ->
[g(Atom, Req) || Atom <- List];