pifantastic/grunt-s3 — pull request #17 by lbeschastny (2012-11-26 13:24:25+00:00)
Title: Default headers overwrites after each task

When default headers is set:
```coffee-script
s3:
key: 'AWS KEY'
secret: 'AWS SECRET'
bucket: 'AWS BUCKET'
access: 'public-read'
headers:
'Cache-Control': "public, max-age=#{60*60*24*cache_lifetime}"
upload: [
{
src: '<%= dirs.dist %>js/*'
dest: 'js/'
gzip: true
}
{
src: 'public/img/*'
dest: 'img/'
}
]
```
Each task in 'uploads' section overwrites global headers, because `getConfig` returns not a copy, but an original `headers` object. So, the following code changes global `headers` object, instead of just a local one:
```java-script
var config = _.defaults(options || {}, getConfig());
var headers = options.headers || {};
```
```java-script
headers['Content-Encoding'] = 'gzip';
headers['Content-Type'] = mime.lookup(src);

var charset = mime.charsets.lookup(headers['Content-Type'], null);
if (charset) {
headers['Content-Type'] += '; charset=' + charset;
}
```
So, all images will be uploaded to `img/` with wrong `Content-Encoding` and `Content-Type` headers.