Skip to content

net/http: server responds with Transfer-Encoding: identity #49194

Closed
@neild

Description

@neild

The net/http server permits setting a Transfer-Encoding: identity header to disable chunked response writes. As of https://golang.org/cl/231418, the net/http client rejects responses with Transfer-Encoding: identity, resulting in cases where a Go client cannot talk to a Go server.

Example case:

func main() {
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                w.Header().Set("Transfer-Encoding", "identity")
                w.WriteHeader(200)
                w.(http.Flusher).Flush()
                fmt.Fprintln(w, "Hello, world.")
        })
        go func() {
                log.Fatal(http.ListenAndServe("127.0.0.1:8080", nil))
        }()
        time.Sleep(1 * time.Second)

        _, err := http.Get("http://127.0.0.1:8080/")
        if err != nil {
                fmt.Println(err)
        }
}
Get "http://127.0.0.1:8080/": net/http: HTTP/1.x transport connection broken: unsupported transfer encoding: "identity"

The server should remove the Transfer-Encoding: identity header from the response (while still disabling chunking).

Related: The server should treat any encoding other than "identity" or "chunked" as an error. https://golang.org/issue/38867

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions