aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_stream_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-03-27 10:26:13 +0200
committerLoïc Hoguin <[email protected]>2017-03-27 10:26:13 +0200
commit10dfd8c910bce3ae71146f8f13eef25b34ec093a (patch)
treee491e7602e69c5eb82dc7ea5b25c269f0c4cd4d2 /src/cowboy_stream_h.erl
parent14a01f71cb495ef6be5e31122857d1e4438cecfe (diff)
downloadcowboy-10dfd8c910bce3ae71146f8f13eef25b34ec093a.tar.gz
cowboy-10dfd8c910bce3ae71146f8f13eef25b34ec093a.tar.bz2
cowboy-10dfd8c910bce3ae71146f8f13eef25b34ec093a.zip
Add the early_error cowboy_stream callback
This callback is called when an error occurs before the request (including headers, excluding body) was fully received. The init/3 callback will not be called. The callback receives the partial Req object (possibly empty), the reason for the error and the response command that the server will send. It allows you to be aware of the error and possibly modify the response before it is sent.
Diffstat (limited to 'src/cowboy_stream_h.erl')
-rw-r--r--src/cowboy_stream_h.erl7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cowboy_stream_h.erl b/src/cowboy_stream_h.erl
index 390f986..ec32ff0 100644
--- a/src/cowboy_stream_h.erl
+++ b/src/cowboy_stream_h.erl
@@ -19,6 +19,7 @@
-export([data/4]).
-export([info/3]).
-export([terminate/3]).
+-export([early_error/5]).
-export([proc_lib_hack/3]).
-export([execute/3]).
@@ -122,6 +123,12 @@ info(_StreamID, _Info, State) ->
terminate(_StreamID, _Reason, _State) ->
ok.
+-spec early_error(cowboy_stream:streamid(), cowboy_stream:reason(),
+ cowboy_stream:partial_req(), Resp, cowboy:opts()) -> Resp
+ when Resp::cowboy_stream:resp_command().
+early_error(StreamID, Reason, PartialReq, Resp, Opts) ->
+ cowboy_stream:early_error(StreamID, Reason, PartialReq, Resp, Opts).
+
%% We use ~999999p here instead of ~w because the latter doesn't
%% support printable strings.
report_crash(_, _, _, normal, _) ->