Use provided request headers in urllib3
outside. However, `Urllib3HttpConnection` did not use these headers but only its default ones. With this commit, `Urllib3HttpConnection` will either use the default ones or merge the default headers with the provided ones if there are any. Relates #618
This commit is contained in:
@@ -142,10 +142,11 @@ class Urllib3HttpConnection(Connection):
|
||||
if not isinstance(method, str):
|
||||
method = method.encode('utf-8')
|
||||
|
||||
request_headers = self.headers
|
||||
if headers:
|
||||
request_headers = dict(self.headers)
|
||||
request_headers.update(headers or {})
|
||||
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
|
||||
request_headers = request_headers.copy()
|
||||
request_headers.update(headers)
|
||||
response = self.pool.urlopen(method, url, body, retries=False, headers=request_headers, **kw)
|
||||
duration = time.time() - start
|
||||
raw_data = response.data.decode('utf-8')
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user