Skip to content

net/http: reuse connection if entire unread body is in buffer #75309

@canoriz

Description

@canoriz

Proposal Details

Currently, if an HTTP response body is closed before fully read (fully means till EOF),
the underlying HTTP connection won't be reused. But in the current implementation,
body is first read into bufio buffer by bufio reader, then from buffer by body Reader.
So even if the body is closed before fully read, as long as the entire body has been
read into buffer, after discard buffer, the connection can be reused.

This will be useful when go client only read body if status is 200 while server sends
HTTP body in a non 200 status response.

I filed a PR #75303 , reviewer suggests opening an issue and discuss it first, so here it is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions