mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 20:50:24 +00:00
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.
This commit is contained in:
parent
14a01f71cb
commit
10dfd8c910
4 changed files with 100 additions and 28 deletions
|
@ -19,6 +19,7 @@
|
|||
-export([data/4]).
|
||||
-export([info/3]).
|
||||
-export([terminate/3]).
|
||||
-export([early_error/5]).
|
||||
|
||||
-record(state, {
|
||||
next :: any(),
|
||||
|
@ -55,6 +56,12 @@ terminate(StreamID, Reason, #state{next=Next, deflate=Z}) ->
|
|||
end,
|
||||
cowboy_stream:terminate(StreamID, Reason, Next).
|
||||
|
||||
-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).
|
||||
|
||||
%% Internal.
|
||||
|
||||
%% Check if the client supports decoding of gzip responses.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue