Skip to content

net/http: Request.ProtoMajor/Minor behavior vs docs discrepancy #18407

Closed
@bradfitz

Description

@bradfitz

The net/http.Request docs say:

        // The protocol version for incoming server requests.
        //
        // For client requests these fields are ignored. The HTTP
        // client code always uses either HTTP/1.1 or HTTP/2.
        // See the docs on Transport for details.
        Proto      string // "HTTP/1.0"
        ProtoMajor int    // 1
        ProtoMinor int    // 0

But that turns out not to be true. transfer.go's func newTransferWriter checks for instance:

        case *Request:
...
                atLeastHTTP11 = rr.ProtoAtLeast(1, 1)
...
                if t.ContentLength < 0 && len(t.TransferEncoding) == 0 && atLeastHTTP11 { 
                        t.TransferEncoding = []string{"chunked"} 
                }

This bug is to audit investigate either fixing the implementation (if possible), or fixing the docs, and auditing any other locations. Hopefully it's fixable and doesn't require documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions