mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http: make NewRequest pick a ContentLength from a *bytes.Reader too
It already did so for its sibling, *strings.Reader, as well as *bytes.Buffer. R=edsrzf, dave, adg, kevlar, remyoudompheng, adg, rsc CC=golang-dev https://golang.org/cl/7031045
This commit is contained in:
parent
cdec0850f8
commit
5e8ca201d1
2 changed files with 33 additions and 2 deletions
|
|
@ -433,10 +433,12 @@ func NewRequest(method, urlStr string, body io.Reader) (*Request, error) {
|
|||
}
|
||||
if body != nil {
|
||||
switch v := body.(type) {
|
||||
case *strings.Reader:
|
||||
req.ContentLength = int64(v.Len())
|
||||
case *bytes.Buffer:
|
||||
req.ContentLength = int64(v.Len())
|
||||
case *bytes.Reader:
|
||||
req.ContentLength = int64(v.Len())
|
||||
case *strings.Reader:
|
||||
req.ContentLength = int64(v.Len())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue