encode/httpcore

Handle HTTP/1.1 half-closed connections gracefully.

tomchristie opened this issue · 0 comments

There's an HTTP/1.1 case that can occur where...

  • The client starts sending a request.
  • The server half-closes the connection.
  • The server sends a response, such as an HTTP 413 Content Too Large.

Currently our behaviour here is that we'll see a WriteError occur here and never get a response.
A more graceful behaviour is handle this case, and return the 413 response.

Prompted via encode/httpx#2503.

A follow up question to this will be... is there an equivalent to this for HTTP/2 streams? But let's only consider that once we've dealt with this as a precursor.