Skip to content

Commit

Permalink
Use provided request headers in urllib3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
honzakral committed Jan 1, 2018
1 parent 2dce4c0 commit a023bdd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions elasticsearch/connection/http_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ def perform_request(self, method, url, params=None, body=None, timeout=None, ign
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:
Expand Down

0 comments on commit a023bdd

Please sign in to comment.