From b52a570377837fcee617114feb24aba8af4f24cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Tue, 8 Mar 2022 11:59:31 +0100 Subject: Make the stream_error_* functions return 'ok' This will make it more obvious what callbacks return. --- src/gun_http.erl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gun_http.erl') diff --git a/src/gun_http.erl b/src/gun_http.erl index ec29b71..d928b18 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -677,10 +677,12 @@ scheme(#http_state{transport=Transport}) -> %% We are expecting a new stream. data(State=#http_state{out=head}, StreamRef, ReplyTo, _, _, _, EvHandlerState) -> - {error_stream_closed(State, StreamRef, ReplyTo), EvHandlerState}; + error_stream_closed(State, StreamRef, ReplyTo), + {[], EvHandlerState}; %% There are no active streams. data(State=#http_state{streams=[]}, StreamRef, ReplyTo, _, _, _, EvHandlerState) -> - {error_stream_not_found(State, StreamRef, ReplyTo), EvHandlerState}; + error_stream_not_found(State, StreamRef, ReplyTo), + {[], EvHandlerState}; %% We can only send data on the last created stream. data(State=#http_state{socket=Socket, transport=Transport, version=Version, out=Out, streams=Streams}, StreamRef, ReplyTo, IsFin, Data, @@ -727,7 +729,8 @@ data(State=#http_state{socket=Socket, transport=Transport, version=Version, {[], EvHandlerState0} end; _ -> - {error_stream_not_found(State, StreamRef, ReplyTo), EvHandlerState0} + error_stream_not_found(State, StreamRef, ReplyTo), + {[], EvHandlerState0} end. connect(State, StreamRef, ReplyTo, _, _, _, _, _, EvHandlerState) @@ -803,7 +806,8 @@ cancel(State0, StreamRef, ReplyTo, EvHandler, EvHandlerState0) -> }, EvHandlerState0), {{state, State}, EvHandlerState}; false -> - {error_stream_not_found(State0, StreamRef, ReplyTo), EvHandlerState0} + error_stream_not_found(State0, StreamRef, ReplyTo), + {[], EvHandlerState0} end. stream_info(#http_state{streams=Streams}, StreamRef) -> @@ -831,12 +835,12 @@ down(#http_state{streams=Streams}) -> error_stream_closed(State, StreamRef, ReplyTo) -> ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef), {badstate, "The stream has already been closed."}}, - {state, State}. + ok. error_stream_not_found(State, StreamRef, ReplyTo) -> ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef), {badstate, "The stream cannot be found."}}, - {state, State}. + ok. %% Headers information retrieval. -- cgit v1.2.3