check content-encoding for chunked

This commit is contained in:
Çağrı 2025-08-02 00:17:42 +00:00 committed by GitHub
parent 1cedefa1c2
commit 7705a8004b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -386,10 +386,11 @@ func setContentLength(req *http.Request) error {
} }
func isTransferEncodingChunked(req *http.Request) bool { func isTransferEncodingChunked(req *http.Request) bool {
contentEncodingVal := req.Header.Get("Content-Encoding") // AWS S3 uses Content-Encoding: aws-chunked
transferEncodingVal := req.Header.Get("Transfer-Encoding") transferEncodingVal := req.Header.Get("Transfer-Encoding")
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding suggests that this can be a comma // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding suggests that this can be a comma
// separated value as well. // separated value as well.
return strings.Contains(strings.ToLower(transferEncodingVal), "chunked") return strings.Contains(strings.ToLower(transferEncodingVal), "chunked") || strings.Contains(strings.ToLower(contentEncodingVal), "chunked")
} }
// A helper struct that guarantees a call to close only affects read side, but not write side. // A helper struct that guarantees a call to close only affects read side, but not write side.