Skip to content

Commit 7949e5a

Browse files
committed
Include headers set by BaseEngine() in requests
BaseEngine.construct_request_kwargs() fails to preserve existing headers set in self.requests by BaseEngine.__init__. Merge the new headers with the existing engine headers. (This was noticed with 'key' for API access via key.) Fixes: #353 Signed-off-by: Dan Mick <[email protected]>
1 parent 8d39a32 commit 7949e5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

redminelib/engines/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def construct_request_kwargs(self, method, headers, params, data):
6060
:param data: (required). Data to send in the body of the request.
6161
:type data: dict, bytes or file-like object
6262
"""
63-
kwargs = dict(self.requests, **{'data': data or {}, 'params': params or {}, 'headers': headers or {}})
63+
# headers may be supplied in __init__; merge in any newly-requested headers
64+
if 'headers' in self.requests:
65+
merged_headers = self.requests['headers'] | (headers or {})
66+
kwargs = dict(self.requests, **{'data': data or {}, 'params': params or {}, 'headers': merged_headers})
6467

6568
if method in ('post', 'put', 'patch') and 'Content-Type' not in kwargs['headers']:
6669
kwargs['data'] = json.dumps(data)

0 commit comments

Comments
 (0)