From f8f05d04e7fa8ea33d7322f20dc900dba290eb40 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 26 Jun 2019 13:38:06 -0700 Subject: [PATCH] Fix trailers without EOS flag to be a stream instead of connection error (#377) [Trailers without EOS](https://httpwg.org/specs/rfc7540.html#HttpSequence): > An endpoint that receives a HEADERS frame without the END_STREAM flag set after receiving a final (non-informational) status code MUST treat the corresponding request or response as malformed (Section 8.1.2.6). [Malformed messages](https://httpwg.org/specs/rfc7540.html#malformed): > Malformed requests or responses that are detected MUST be treated as a stream error (Section 5.4.2) of type PROTOCOL_ERROR. --- src/proto/streams/streams.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 4f44edf..cfdf5a3 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -204,9 +204,13 @@ where } } else { if !frame.is_end_stream() { - // TODO: Is this the right error - proto_err!(conn: "recv_headers: trailers frame was not EOS; stream={:?}", stream.id); - return Err(RecvError::Connection(Reason::PROTOCOL_ERROR)); + // Receiving trailers that don't set EOS is a "malformed" + // message. Malformed messages are a stream error. + proto_err!(stream: "recv_headers: trailers frame was not EOS; stream={:?}", stream.id); + return Err(RecvError::Stream { + id: stream.id, + reason: Reason::PROTOCOL_ERROR, + }); } actions.recv.recv_trailers(frame, stream)