Enable global HTTP headers to be sent with every request.
This commit is contained in:
@@ -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'] = (
|
||||
|
||||
Reference in New Issue
Block a user