Skip to content

Commit 49a0354

Browse files
committed
[lib] Change boto2 to not override the User Agent if already present
This enables to reuse the boto HttpRequest client with Raz signed URLs. The Raz URLs are signed and the User Agent is part of the signature, so this one should not be changed.
1 parent 6bf8397 commit 49a0354

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

desktop/core/ext-py/boto-2.46.1/boto/connection.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ def authorize(self, connection, **kwargs):
372372
self.headers[key] = quote(val.encode('utf-8'), safe)
373373
setattr(self, '_headers_quoted', True)
374374

375-
self.headers['User-Agent'] = UserAgent
375+
if not self.headers('User-Agent'):
376+
self.headers['User-Agent'] = UserAgent
376377

377378
connection._auth_handler.add_auth(self, **kwargs)
378379

desktop/core/ext-py/boto-2.46.1/boto/s3/key.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,10 @@ def sender(http_conn, method, path, data, headers):
890890
else:
891891
headers = headers.copy()
892892
# Overwrite user-supplied user-agent.
893-
for header in find_matching_headers('User-Agent', headers):
894-
del headers[header]
895-
headers['User-Agent'] = UserAgent
893+
#for header in find_matching_headers('User-Agent', headers):
894+
# del headers[header]
895+
if not headers.get('User-Agent'):
896+
headers['User-Agent'] = UserAgent
896897
# If storage_class is None, then a user has not explicitly requested
897898
# a storage class, so we can assume STANDARD here
898899
if self._storage_class not in [None, 'STANDARD']:

0 commit comments

Comments
 (0)