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 http.Transport will use chunked Encoding automatically when Request has body and Request.Content-Length was set < 0. But this troubled me when I use net.http in my own penetration testing tool, which always need to build a custom chunked body. The code simply looks like the following snippet:
Howover, it didn't work as expected. I tried to trace the roundtrip method and found that Transfer-Encoding is in a map named reqWriteExcludeHeader, which looks like a whitelist when writing request header.
And if I set req.Transfer-Encoding = []string{"chunked"}, the request body will be chunked twice! one from my customChunkedWriter, the other from the internal chunked writer.
Finally, I believe there is actually no way to make it. I think It's not a intended behavior. It should be great if it acts like Accept-Encoding.
If the Transport requests gzip on its own and gets a gzipped response, it's transparently decoded in the Response.Body. However, if the user explicitly requested gzip it is not automatically uncompressed.
If I send Transfer-Encoding explicitly, transport should keep the header and do nothing about the request body.
What did you see instead?
Described as above.
The text was updated successfully, but these errors were encountered:
bcmills
changed the title
net:http Transport doesn't support specify Transfer-Encoding explicitly
net/http: Transport doesn't support specify Transfer-Encoding explicitly
Aug 20, 2019
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I know
http.Transport
will usechunked
Encoding automatically whenRequest
has body andRequest.Content-Length
was set < 0. But this troubled me when I use net.http in my own penetration testing tool, which always need to build a custom chunked body. The code simply looks like the following snippet:Howover, it didn't work as expected. I tried to trace the
roundtrip
method and found thatTransfer-Encoding
is in a map namedreqWriteExcludeHeader
, which looks like a whitelist when writing request header.And if I set
req.Transfer-Encoding = []string{"chunked"}
, the request body will be chunked twice! one from my customChunkedWriter, the other from the internal chunked writer.Finally, I believe there is actually no way to make it. I think It's not a intended behavior. It should be great if it acts like
Accept-Encoding
.Related issue: #28026
What did you expect to see?
If I send
Transfer-Encoding
explicitly, transport should keep the header and do nothing about the request body.What did you see instead?
Described as above.
The text was updated successfully, but these errors were encountered: