Skip to content

fix(h1): close without lingering after a response that completed before its request #1738

Closed

Description

@FlorentinDUBOIS

When an H1 response completes before its request was received whole (an early 413 or 401 on an upload, or a backend Connection: close response mid-upload), sozu closes the client connection as soon as the response is flushed (#1721, defer_close_for_tls_flush("request-incomplete") in lib/src/protocol/mux/h1.rs).

That close is immediate: shutdown(SHUT_WR) followed by close(2) in the same pass (HttpSession::close / HttpsSession::close). Nothing reads what the client is still sending. When the receive queue is not empty at the close, or more data arrives after it, the kernel sends a reset, which discards the part of the response still queued in sozu's socket. The client can then lose the response it was meant to read.

RFC 9112 §9.6 recommends a staged close for this case: half-close the write side, keep reading (and discarding) for a bounded time, then close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions