Skip to content

Commit

Permalink
fix: Fix canonical headers including or not including specific config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
Marco Klein authored and mhart committed Aug 6, 2024
1 parent 7e2d1cb commit 3c9c923
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion aws4.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,15 @@ RequestSigner.prototype.canonicalHeaders = function() {
function trimAll(header) {
return header.toString().trim().replace(/\s+/g, ' ')
}

var extraHeadersToInclude = this.extraHeadersToInclude,
extraHeadersToIgnore = this.extraHeadersToIgnore

return Object.keys(headers)
.filter(function(key) { return HEADERS_TO_IGNORE[key.toLowerCase()] == null })
.filter(function(key) {
return extraHeadersToInclude[key.toLowerCase()] ||
(HEADERS_TO_IGNORE[key.toLowerCase()] == null && !extraHeadersToIgnore[key.toLowerCase()])
})
.sort(function(a, b) { return a.toLowerCase() < b.toLowerCase() ? -1 : 1 })
.map(function(key) { return key.toLowerCase() + ':' + trimAll(headers[key]) })
.join('\n')
Expand Down

0 comments on commit 3c9c923

Please sign in to comment.