Skip to content

net/http: Client support for Expect: 100-continue #3665

@bradfitz

Description

@bradfitz
The http Client should probably support Expect: 100-continue.  The server does.

It does introduce a new round-trip, though, so we should probably only send it when the
data size exceeds some threshold.  Probably the same threshold we use for consuming
request bodies when a handler doesn't (maxPostHandlerReadBytes).

I think we could see if we know the size of the request body (just as NewRequest does,
checking for a few known types), but if the Body is non-nil and the ContentLength is
<=0 (unknown), we instead slurp up the Body into a bytes.Buffer to see if it's >=
someThreshold.  If so, we replace the Body with a io.MultiReader(slurped, rest) and
proceed to do a 100-continue.  If not, we blast it away HTTP/1.0-style.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions