New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: client Expect: 100-continue
reads first byte of input on failure
#16002
Comments
It might be worth noting that the playground example works as expected if |
I don't think it is entirely documentation, so removing the label. I'd like to address a bunch of the redirect-related bugs in 1.8, and this falls under that. |
CL https://golang.org/cl/30087 mentions this issue. |
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
CL https://golang.org/cl/30151 mentions this issue. |
CL https://golang.org/cl/30150 mentions this issue. |
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
I'm trying to use
Expect: 100-continue
from the net/http client so that I can retry (after refreshing the token) requests with a body when I get a 401 request.Do do this I'm passing in an
io.Reader
intohttp.NewRequest
and setting the header thusHowever 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.
Playground demonstration
What version of Go are you using (
go version
)?Fails on stable and tip
What operating system and processor architecture are you using (
go env
)?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: