Permalink
Browse files

Merge pull request #344 from nathan-lafreniere/master

Make AWS auth signing find headers correctly
  • Loading branch information...
2 parents bfe2791 + 288c52a commit c06c394cac97bdfeb5ee9efb21cf9af5b0f05807 @mikeal mikeal committed Nov 6, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 main.js
View
13 main.js
@@ -808,6 +808,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
@@ -820,8 +829,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) {

0 comments on commit c06c394

Please sign in to comment.