Skip to content

Commit

Permalink
fix S3 client no longer honor the computeChecksums config (#4052)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP authored Mar 11, 2022
1 parent 80bee5c commit 82d8972
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-S3-36a7ac77.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "S3",
"description": "Fixed a bug that S3 client no longer honor the computeChecksums config introduced in #3799. Previously only the members with httpChecksumRequired trait will be disabled by unseting computeChecksums config. S3 doesn't not honor the config because it has its own logic handling MD5 chechsums."
}
3 changes: 2 additions & 1 deletion lib/services/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ AWS.util.update(AWS.S3.prototype, {
willComputeChecksums: function willComputeChecksums(req) {
var rules = req.service.api.operations[req.operation].input.members;
var body = req.httpRequest.body;
var needsContentMD5 = rules.ContentMD5 &&
var needsContentMD5 = req.service.config.computeChecksums &&
rules.ContentMD5 &&
!req.params.ContentMD5 &&
body &&
(AWS.util.Buffer.isBuffer(req.httpRequest.body) || typeof req.httpRequest.body === 'string');
Expand Down
10 changes: 5 additions & 5 deletions scripts/region-checker/allowlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ var allowlist = {
262,
275,
281,
640,
642,
761,
772,
641,
643,
762,
773,
774,
779
775,
780,
]
};

Expand Down
21 changes: 21 additions & 0 deletions test/services/s3.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,27 @@ describe('AWS.S3', function() {
}
};

it('does not compute checksums if computeChecksums is off', function() {
willCompute('putObject', {
computeChecksums: false,
hash: null
});
});

it('does not compute checksums if computeChecksums is on and ContentMD5 is provided', function() {
willCompute('putBucketAcl', {
computeChecksums: true,
hash: '000'
});
});

it('computes checksums if computeChecksums is on and ContentMD5 is not provided', function() {
willCompute('putBucketAcl', {
computeChecksums: true,
hash: '1B2M2Y8AsgTpgAmY7PhCfg=='
});
});

if (AWS.util.isNode()) {
it('does not compute checksums for Stream objects', function() {
s3 = new AWS.S3({
Expand Down

0 comments on commit 82d8972

Please sign in to comment.