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: can't set Transfer-Encoding explicitly on outgoing Request #28026
Comments
DumpRequestOut is implemented with the actual http.Transport writing to a buffer. Are you actually seeing it appear on the wire but not in DumpRequestOut? |
So I had thought that this data was being sent since I was able to send the request to a test server, respond with it back, and the TransferEncoding was still set appropriately. However I've now used wireshark to check and it is not actually sent in the request. https://golang.org/src/net/http/transfer.go?h=writeHeader#L107 seems to show that the https://play.golang.org/p/pM6PmzpsaX7 is a minimal example which has one line commented out which, if toggled, changes the output. Transfer encoding set (and only to chunked) when:
That means there is no way to ever actually set any other TransferEncoding and if you try to manually set it to chunked it actually prevents the message from being sent with the chunked transfer encoding. Is that the intended behavior? I've never actually wanted to change the TE but I was developing a tool to modify/send requests and assumed that someone might need to change that field. Maybe that is just an unnecessary concern? |
/remove WaitingForInfo |
Back to @bradfitz to decide. |
so no way to set http header "Transfer-Encoding" header util Go1.15? |
httputil.DumpRequestOut
does not currently print anything w.r.t.Transfer-Encoding
(TE) even though the information is printed viaDumpRequest
. In addition, there is special logic for handling TE that seems like maybe it hasn't been extracted out so the logic is hard-coded intoDumpRequest
which means that it could drift from what is actually done when sending the request.I've not spent too much time looking at possible solutions but the Transfer-Encoding definitely seems to be a special case and its not particularly intuitive whats going on to your request if you set the header field manually or if you set the request.TransferEncoding.
The docs say that
DumpRequest
is for server side debugging whereasDumpRequestOut
is for clientside, but I'm not familiar with why they couldn't/shouldn't be more similar (or the same).Not sure if this logic should be put into
DumpRequestOut
, if not, why? And I'd like to get a bit of feedback if this is a known issue that maintainers would like to have cleaned up.What version of Go are you using (
go version
)?Go playground, any go version as far as I'm aware.
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?Just using the playground as an example.
What did you do?
https://play.golang.org/p/vW7oNw0Jjz6
What did you expect to see?
The same information for Transfer-Encoding available on both
Dump...
outputs.What did you see instead?
Transfer-Encoding is printed during
DumpRequest
but notDumpRequestOut
The text was updated successfully, but these errors were encountered: