Skip to content

net/http: clarify docs on ResponseWriter.Write and Response.Write #8991

Closed
@gopherbot

Description

@gopherbot

by opennota:

When writing to the http.ResponseWriter, the http.Response's method Write doesn't do
what is expected.

    func handler(w http.ResponseWriter, r *http.Request) {
        resp, _ := client.Get("http://google.com/";)
        resp.Write(w)
    }

This will write resp's headers to the *body* of the handler's response, with the
text/plain content type.

A method that *copies* a Response would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions