net/http: close Body in client code always, even on errors, and document

Fixes #6981

LGTM=rsc
R=golang-codereviews, nightlyone
CC=adg, dsymonds, golang-codereviews, rsc
https://golang.org/cl/85560045
This commit is contained in:
Brad Fitzpatrick 2014-04-14 08:06:13 -07:00
parent 0d441a088d
commit a8d90ec350
4 changed files with 70 additions and 3 deletions

View file

@ -867,3 +867,9 @@ func (r *Request) wantsHttp10KeepAlive() bool {
func (r *Request) wantsClose() bool {
return hasToken(r.Header.get("Connection"), "close")
}
func (r *Request) closeBody() {
if r.Body != nil {
r.Body.Close()
}
}