Skip to content

Commit

Permalink
Add the ability to specify default headers used in future requests. F…
Browse files Browse the repository at this point in the history
…or example this gives you the ability to set Connection.default_headers = {'Prefer': 'outlook.body-content-type="text"'}, to request to be sent text instead of html from outlook for future calls.
  • Loading branch information
Nathan Thomas committed Jul 11, 2018
1 parent 9ef3698 commit 90120a8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions O365/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def delete_token(token_path=None):
class Connection(with_metaclass(Singleton)):
_oauth2_authorize_url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
_oauth2_token_url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
default_headers = None

def __init__(self):
""" Creates a O365 connection object """
Expand Down Expand Up @@ -196,6 +197,8 @@ def get_response(request_url, **kwargs):
con_params = {}
if connection.proxy_dict:
con_params['proxies'] = connection.proxy_dict
if connection.default_headers:
con_params['headers'] = connection.default_headers
con_params.update(kwargs)

log.info('Requesting URL: {}'.format(request_url))
Expand Down

0 comments on commit 90120a8

Please sign in to comment.