Skip to content

Commit

Permalink
switch to a case insensitive getter when fetching headers for aws aut…
Browse files Browse the repository at this point in the history
…h signing
  • Loading branch information
nlf committed Oct 15, 2012
1 parent 6db4a7c commit 288c52a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,15 @@ Request.prototype.json = function (val) {
}
return this
}
function getHeader(name, headers) {
var result, re, match
Object.keys(headers).forEach(function (key) {
re = new RegExp(name, 'i')
match = key.match(re)
if (match) result = headers[key]
})
return result
}
Request.prototype.aws = function (opts, now) {
if (!now) {
this._aws = opts
Expand All @@ -811,8 +820,8 @@ Request.prototype.aws = function (opts, now) {
, secret: opts.secret
, verb: this.method.toUpperCase()
, date: date
, contentType: this.headers['content-type'] || ''
, md5: this.headers['content-md5'] || ''
, contentType: getHeader('content-type', this.headers) || ''
, md5: getHeader('content-md5', this.headers) || ''
, amazonHeaders: aws.canonicalizeHeaders(this.headers)
}
if (opts.bucket && this.path) {
Expand Down

0 comments on commit 288c52a

Please sign in to comment.