@@ -84,8 +84,10 @@ class InfluxDBClient(object):
84
84
:param session: allow for the new client request to use an existing
85
85
requests Session, defaults to None
86
86
: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
87
90
:raises ValueError: if cert is provided but ssl is disabled (set to False)
88
-
89
91
"""
90
92
91
93
def __init__ (self ,
@@ -106,6 +108,7 @@ def __init__(self,
106
108
cert = None ,
107
109
gzip = False ,
108
110
session = None ,
111
+ headers = None ,
109
112
):
110
113
"""Construct a new InfluxDBClient object."""
111
114
self .__host = host
@@ -166,10 +169,11 @@ def __init__(self,
166
169
self ._port ,
167
170
self ._path )
168
171
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
173
177
174
178
self ._gzip = gzip
175
179
@@ -390,7 +394,7 @@ def write(self, data, params=None, expected_response_code=204,
390
394
:returns: True, if the write operation is successful
391
395
:rtype: bool
392
396
"""
393
- headers = self ._headers
397
+ headers = self ._headers . copy ()
394
398
headers ['Content-Type' ] = 'application/octet-stream'
395
399
396
400
if params :
0 commit comments