From cbbb4d5523f8738b237593f9516c3a237d0cc2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 15 Nov 2017 14:39:36 +0100 Subject: Add preliminary support for trailers The code is definitely not the best, but as long as it doesn't break anything it should be OK for now. --- src/gun_http2.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gun_http2.erl') diff --git a/src/gun_http2.erl b/src/gun_http2.erl index decc206..cc57f65 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -160,9 +160,15 @@ frame({headers, StreamID, IsFin, head_fin, HeaderBlock}, remote_fin(Stream#stream{handler_state=Handlers}, State#http2_state{decode_state=DecodeState}, IsFin) end; + %% @todo For now we assume that it's a trailer if there's no :status. + %% A better state machine is needed to distinguish between that and errors. false -> - stream_reset(State, StreamID, {stream_error, protocol_error, - 'Malformed response; missing :status in HEADERS frame. (RFC7540 8.1.2.4)'}) + %% @todo We probably want to pass this to gun_content_handler? + ReplyTo ! {gun_trailers, self(), StreamRef, Headers0}, + remote_fin(Stream, State#http2_state{decode_state=DecodeState}, fin) +%% false -> +%% stream_reset(State, StreamID, {stream_error, protocol_error, +%% 'Malformed response; missing :status in HEADERS frame. (RFC7540 8.1.2.4)'}) end catch _:_ -> terminate(State, StreamID, {connection_error, compression_error, -- cgit v1.2.3