Enable global HTTP headers to be sent with every request.

This commit is contained in:
2016-07-20 14:27:45 +02:00
parent 67bf7e0df5
commit f47dcd2a31

View File

@@ -1,3 +1,4 @@
import copy
import base64
import requests
import json
@@ -23,6 +24,9 @@ class Api(object):
# Global session object to do HTTP requests.
requests_session = requests.session()
# HTTP headers that should always be sent with every request.
global_headers = {}
def __init__(self, options=None, **kwargs):
"""Create API object
@@ -158,11 +162,12 @@ class Api(object):
"""
token = self.get_token()
headers = {
headers = copy.deepcopy(self.global_headers)
headers.update({
# "Content-Type": "application/json",
"Accept": "application/json",
"User-Agent": self.user_agent
}
})
if token:
headers['Authorization'] = (