diff --git a/scrapy/core/downloader/handlers/s3.py b/scrapy/core/downloader/handlers/s3.py index dd7bce2be..d8bbdd326 100644 --- a/scrapy/core/downloader/handlers/s3.py +++ b/scrapy/core/downloader/handlers/s3.py @@ -82,7 +82,7 @@ class S3DownloadHandler(object): awsrequest = botocore.awsrequest.AWSRequest( method=request.method, url='%s://s3.amazonaws.com/%s%s' % (scheme, bucket, path), - headers=request.headers.to_native_string_dict(), + headers=request.headers.to_unicode_dict(), data=request.body) self._signer.add_auth(awsrequest) request = request.replace( diff --git a/scrapy/http/headers.py b/scrapy/http/headers.py index d0c4cd0fb..62507eb19 100644 --- a/scrapy/http/headers.py +++ b/scrapy/http/headers.py @@ -79,7 +79,10 @@ class Headers(CaselessDict): def to_string(self): return headers_dict_to_raw(self) - def to_native_string_dict(self): + def to_unicode_dict(self): + """ Return headers as a CaselessDict with unicode keys + and unicode values. Multiple values are joined with ','. + """ return CaselessDict( (to_unicode(key, encoding=self.encoding), to_unicode(b','.join(value), encoding=self.encoding))