Description
Currently NewRequest
type switches on *bytes.Buffer
, *bytes.Reader
and *strings.Reader
to determine whether the body's content length is known and so can be used to set the ContentLength
header. It would be helpful in some cases for other io.Reader
s that are aware of their length to be able to be used in the same way by adding an interface { Len() int }
case.
In AusOcean code we have seen two bugs arising from this since we send requests with an internal io.Reader
that is not one of the three blessed types. For whatever reason, likely a bug in dev_appengine.py
(during CI testing) this results in an error from the request that is avoided if the data is first copied into a *bytes.Buffer
.
The addition of a interface { Len() int }
case looks like it can not be used in conjunction with GetBody
without use of reflect, though I'm not sure how significant this is.
See also https://groups.google.com/d/topic/golang-nuts/NdeMVAamx8E/discussion