Skip to content

Commit

Permalink
Merge pull request #1042 from Invincibear/patch-6
Browse files Browse the repository at this point in the history
Add support for multiple Prefer headers in Connection class
  • Loading branch information
alejcas authored Feb 1, 2024
2 parents 26f1751 + 9c2feb9 commit 417d8cf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion O365/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,16 @@ def _internal_request(self, request_obj, url, method, **kwargs):
"""
method = method.lower()
if method not in self._allowed_methods:
raise ValueError('Method must be one of the allowed ones')
raise ValueError('Method must be one of: {}'.format(self._allowed_methods))

if 'headers' not in kwargs:
kwargs['headers'] = {**self.default_headers}
else:
for key, value in self.default_headers.items():
if key not in kwargs['headers']:
kwargs['headers'][key] = value
elif key == 'Prefer' and key in kwargs['headers']:
kwargs['headers'][key] = "{}, {}".format(kwargs['headers'][key], value)

if method == 'get':
kwargs.setdefault('allow_redirects', True)
Expand Down

0 comments on commit 417d8cf

Please sign in to comment.