You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this is documented that 'a value of 0 means unknown if Body is not nil', but could it be possible to do some fix and not break our old code.
The text was updated successfully, but these errors were encountered:
SunRunAway
changed the title
net/http: client do not set Content-Length: 0
net/http: client do not set Content-Length: 0 with an io.Reader with no bytes.
May 5, 2017
Use nil or the new Go 1.8 http.NoBody to send a Content-Length of 0 if your peer is sensitive to the difference between chunked zero and content-length zero.
We have many interface like below, and every implement with http package should be fixed up for the compatibility unless we know exactly which server is sensitive to the explicit content-length.
@SunRunAway, we considered this a lot during the past cycle, weighing various trade-offs. In the end we decided this was the best thing to do. If you want to be involved in such decisions in the future, please test the beta & rc releases. That's when we can still make changes. Now that Go 1.8 is out, things aren't changing.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
I called http.NewRequest and explicitly set req.ContentLength to 0.
What did you expect to see?
server should get a header with Content-Length: 0
What did you see instead?
With go1.8.1, server get a chunked request body, but older version get a explicit Content-Length header.
I know this is documented that 'a value of 0 means unknown if Body is not nil', but could it be possible to do some fix and not break our old code.
The text was updated successfully, but these errors were encountered: