aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_stream_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/cowboy_stream_h.erl')
-rw-r--r--src/cowboy_stream_h.erl19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/cowboy_stream_h.erl b/src/cowboy_stream_h.erl
index 9f42acc..b373344 100644
--- a/src/cowboy_stream_h.erl
+++ b/src/cowboy_stream_h.erl
@@ -1,4 +1,4 @@
-%% Copyright (c) 2016-2017, Loïc Hoguin <[email protected]>
+%% Copyright (c) 2016-2024, Loïc Hoguin <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
@@ -151,6 +151,11 @@ info(StreamID, Exit={'EXIT', Pid, {Reason, Stacktrace}}, State=#state{ref=Ref, p
[Ref, self(), StreamID, Pid, Reason, Stacktrace]}
|Commands0]
end,
+ %% @todo We are trying to send a 500 response before resetting
+ %% the stream. But due to the way the RESET_STREAM frame
+ %% works in QUIC the data may be lost. The problem is
+ %% known and a draft RFC exists at
+ %% https://www.ietf.org/id/draft-ietf-quic-reliable-stream-reset-03.html
do_info(StreamID, Exit, [
{error_response, 500, #{<<"content-length">> => <<"0">>}, <<>>}
|Commands], State);
@@ -235,9 +240,13 @@ info(StreamID, Data0={data, Pid, _, _}, State0=#state{stream_body_status=Status}
end,
Data = erlang:delete_element(2, Data0),
do_info(StreamID, Data, [Data], State);
-info(StreamID, Alarm={alarm, Name, on}, State)
+info(StreamID, Alarm={alarm, Name, on}, State0=#state{stream_body_status=Status})
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
- do_info(StreamID, Alarm, [], State#state{stream_body_status=blocking});
+ State = case Status of
+ normal -> State0#state{stream_body_status=blocking};
+ _ -> State0
+ end,
+ do_info(StreamID, Alarm, [], State);
info(StreamID, Alarm={alarm, Name, off}, State=#state{stream_body_pid=Pid, stream_body_status=Status})
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
_ = case Status of
@@ -290,7 +299,9 @@ request_process(Req, Env, Middlewares) ->
try
execute(Req, Env, Middlewares)
catch
- exit:Reason:Stacktrace ->
+ exit:Reason={shutdown, _}:Stacktrace ->
+ erlang:raise(exit, Reason, Stacktrace);
+ exit:Reason:Stacktrace when Reason =/= normal, Reason =/= shutdown ->
erlang:raise(exit, {Reason, Stacktrace}, Stacktrace)
end.