Skip to content
Browse files

Fixed an issue with extra headers in generated URLs. Fixes http://cod…

  • Loading branch information...
1 parent 90c6475 commit c220b4b9e95213ffe6ad4e36d4742e421b1b7740 @garnaat garnaat committed
Showing with 8 additions and 5 deletions.
  1. +5 −5 boto/s3/connection.py
  2. +3 −0 tests/s3/test_connection.py
View
10 boto/s3/connection.py
@@ -275,11 +275,11 @@ def generate_url(self, expires_in, method, bucket='', key='',
self.calling_format.build_path_base(bucket, key)
if query_auth:
query_part = '?' + self.QueryString % (encoded_canonical, expires,
- self.aws_access_key_id)
- sec_hdr = self.provider.security_token_header
- if sec_hdr in headers:
- query_part += ('&%s=%s' % (sec_hdr,
- urllib.quote(headers[sec_hdr])));
+ self.aws_access_key_id)
+ hdrs = [ '%s=%s'%(name, urllib.quote(val)) for name,val in headers.items() ]
+ q_str = '&'.join(hdrs)
+ if q_str:
+ query_part += '&' + q_str
else:
query_part = ''
if force_http:
View
3 tests/s3/test_connection.py
@@ -67,6 +67,9 @@ def test_1_basic(self):
url = k.generate_url(3600, force_http=True)
file = urllib.urlopen(url)
assert s1 == file.read(), 'invalid URL %s' % url
+ url = k.generate_url(3600, force_http=True, headers={'x-amz-x-token' : 'XYZ'})
+ file = urllib.urlopen(url)
+ assert s1 == file.read(), 'invalid URL %s' % url
bucket.delete_key(k)
# test a few variations on get_all_keys - first load some data
# for the first one, let's override the content type

0 comments on commit c220b4b

Please sign in to comment.
Something went wrong with that request. Please try again.