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
The text was updated successfully, but these errors were encountered:
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 <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Ian Lance Taylor <email@example.com> Reviewed-by: Joe Tsai <firstname.lastname@example.org>
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 <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Ian Lance Taylor <email@example.com>