Skip to content

Commit

Permalink
Keep body if request uses chunked TransferEncoding
Browse files Browse the repository at this point in the history
Fixes #151
  • Loading branch information
Luis Gerhorst committed Jul 26, 2023
1 parent 26b15d8 commit 892d5f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion handler/proxy_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ func (p *ProxyClient) Do(req *http.Request) (*http.Response, error) {
// to magically set Transfer-Encoding: chunked. Service like S3 does not support chunk encoding.
// We need to manipulate the Body value after signv4 signing because the signing process wraps
// the original body into another struct, which will result in Transfer-Encoding: chunked being set.
if proxyReq.ContentLength == 0 {
//
// If the original request has the outermost "chunked" TransferEncoding, do
// not remove the body as the ContentLength header will then be missing
// (which Go reports as a length of 0).
if proxyReq.ContentLength == 0 && !(len(req.TransferEncoding) >= 1 && req.TransferEncoding[0] == "chunked") {
proxyReq.Body = http.NoBody
}

Expand Down

0 comments on commit 892d5f3

Please sign in to comment.