Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: client `Expect: 100-continue` reads first byte of input on failure #16002
I'm trying to use
Do do this I'm passing in an
req, err := http.NewRequest("PUT", url, body) // err handling req.Header.Set("Expect", "100-continue")
However what I find is that 1 byte gets read from the reader even if the request fails with a 401 error.
This means that I can't retry the request as 1 byte is now missing from the reader.
It might be that this is working as intended, in which case this behavior should be documented.
What version of Go are you using (
Fails on stable and tip
What operating system and processor architecture are you using (
What did you do?
See https://play.golang.org/p/3jXlWyrgsa for example program
What did you expect to see?
No bytes read from reader on 401 error
What did you see instead?
1 bytes read from the reader
Code movement only, to look more like the equivalent http2 code, and to make an upcoming fix look more obvious. Updates #16002 (to be fixed once this code is in) Change-Id: Iaa4f965be14e98f9996e7c4624afe6e19bed1a80 Reviewed-on: https://go-review.googlesource.com/30087 Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org> Reviewed-by: Joe Tsai <email@example.com>
Tests in net/http: TestNoSniffExpectRequestBody_h2 Updates golang/go#16002 Change-Id: Ib5255c14f0a8fdafd36077b86442dff213815567 Reviewed-on: https://go-review.googlesource.com/30150 Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>