From 560c9ccf4b6b0bd89b40fd1dbbdc96b00121b2fb Mon Sep 17 00:00:00 2001 From: Tianyi Wang Date: Thu, 2 Nov 2023 15:43:04 -0400 Subject: [PATCH] Modify and Merge request compression middleware logic --- aws/middleware/request_compression.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws/middleware/request_compression.go b/aws/middleware/request_compression.go index 480fc9f5560..65bc5bef6f8 100644 --- a/aws/middleware/request_compression.go +++ b/aws/middleware/request_compression.go @@ -54,11 +54,11 @@ func (m requestCompression) HandleBuild( return out, metadata, fmt.Errorf("failed to compress request stream, %v", err) } - if newReq, err := req.SetStream(bytes.NewReader(compressedBytes)); err != nil { + var newReq *smithyhttp.Request + if newReq, err = req.SetStream(bytes.NewReader(compressedBytes)); err != nil { return out, metadata, fmt.Errorf("failed to set request stream, %v", err) - } else { - *req = *newReq } + *req = *newReq isCompressed = true } else if req.ContentLength >= m.requestMinCompressSizeBytes { compressedBytes, err := compress(req.Body)