Skip to content

net/http: document that closing a http.Response.Body without first reading it closes the connection #6700

Closed
@schmichael

Description

@schmichael
tl;dr - summarize http://golang.org/src/pkg/net/http/transport.go#L942 in the
http.Response.Body docs: http://tip.golang.org/pkg/net/http/#Response

Perhaps: "Calling Body.Close() before reading the entire response will cause the
underlying connection to be closed."

What steps will reproduce the problem?

http://play.golang.org/p/ue3kwSEb37 (Requires net/http.Get so you have to copy it
locally)

What is the expected output?

Output is as expected once you understand the importance of reading the Response.Body
before closing it.

What do you see instead?

"cannot assign requested address" due to ephemeral port exhaustion.

Which operating system are you using?

Linux / Ubuntu 13.10

Which version are you using?  (run 'go version')

1.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions