encode / httpcore

A minimal HTTP client. ⚙️
https://www.encode.io/httpcore/
BSD 3-Clause "New" or "Revised" License
456 stars 99 forks source link

Handle HTTP/2 half-closed connections gracefully #775

Open karpetrosyan opened 1 year ago

karpetrosyan commented 1 year ago

Discussion: #750 Refs: #641

This is the same as #723 but for http/2 connections

tomchristie commented 1 year ago

So the equivalent for HTTP/2 here is this...

https://httpwg.org/specs/rfc7540.html#HttpSequence

An HTTP response is complete after the server sends — or the client receives — a frame with the END_STREAM flag set (including any CONTINUATION frames needed to complete a header block). A server can send a complete response prior to the client sending an entire request if the response does not depend on any portion of the request that has not been sent and received. When this is true, a server MAY request that the client abort transmission of a request without error by sending a RST_STREAM with an error code of NO_ERROR after sending a complete response (i.e., a frame with the END_STREAM flag). Clients MUST NOT discard responses as a result of receiving such a RST_STREAM, though clients can always discard responses at their discretion for other reasons.

We haven't had any users observe or request this so we don't need to treat it as high priority. Starting out with a test case for this sequence of frames would be the way to go. I'm not sure what our behaviour currently is here.