@@ -84,8 +84,10 @@ class InfluxDBClient(object):
8484 :param session: allow for the new client request to use an existing
8585 requests Session, defaults to None
8686 :type session: requests.Session
87+ :param headers: headers to add to Requests, will add 'Content-Type'
88+ and 'Accept' unless these are already present, defaults to {}
89+ :type headers: dict
8790 :raises ValueError: if cert is provided but ssl is disabled (set to False)
88-
8991 """
9092
9193 def __init__ (self ,
@@ -106,6 +108,7 @@ def __init__(self,
106108 cert = None ,
107109 gzip = False ,
108110 session = None ,
111+ headers = None ,
109112 ):
110113 """Construct a new InfluxDBClient object."""
111114 self .__host = host
@@ -166,10 +169,11 @@ def __init__(self,
166169 self ._port ,
167170 self ._path )
168171
169- self ._headers = {
170- 'Content-Type' : 'application/json' ,
171- 'Accept' : 'application/x-msgpack'
172- }
172+ if headers is None :
173+ headers = {}
174+ headers .setdefault ('Content-Type' , 'application/json' )
175+ headers .setdefault ('Accept' , 'application/x-msgpack' )
176+ self ._headers = headers
173177
174178 self ._gzip = gzip
175179
@@ -390,7 +394,7 @@ def write(self, data, params=None, expected_response_code=204,
390394 :returns: True, if the write operation is successful
391395 :rtype: bool
392396 """
393- headers = self ._headers
397+ headers = self ._headers . copy ()
394398 headers ['Content-Type' ] = 'application/octet-stream'
395399
396400 if params :
0 commit comments