@@ -237,14 +237,8 @@ def __init__(self,
237
237
self .__conn = httplib .HTTPConnection (self .__url .hostname , port = port ,
238
238
timeout = timeout )
239
239
240
- def _call (self , service_name , * args ):
241
- self .__id_count += 1
242
-
243
- postdata = json .dumps ({'version' : '1.1' ,
244
- 'method' : service_name ,
245
- 'params' : args ,
246
- 'id' : self .__id_count })
247
-
240
+ @property
241
+ def _headers (self ):
248
242
headers = {
249
243
'Host' : self .__url .hostname ,
250
244
'User-Agent' : DEFAULT_USER_AGENT ,
@@ -254,7 +248,18 @@ def _call(self, service_name, *args):
254
248
if self .__auth_header is not None :
255
249
headers ['Authorization' ] = self .__auth_header
256
250
257
- self .__conn .request ('POST' , self .__url .path , postdata , headers )
251
+ return headers
252
+
253
+ def _call (self , service_name , * args ):
254
+ self .__id_count += 1
255
+
256
+ postdata = json .dumps ({'version' : '1.1' ,
257
+ 'method' : service_name ,
258
+ 'params' : args ,
259
+ 'id' : self .__id_count })
260
+
261
+
262
+ self .__conn .request ('POST' , self .__url .path , postdata , self ._headers )
258
263
259
264
response = self ._get_response ()
260
265
err = response .get ('error' )
@@ -272,17 +277,7 @@ def _call(self, service_name, *args):
272
277
273
278
def _batch (self , rpc_call_list ):
274
279
postdata = json .dumps (list (rpc_call_list ))
275
-
276
- headers = {
277
- 'Host' : self .__url .hostname ,
278
- 'User-Agent' : DEFAULT_USER_AGENT ,
279
- 'Content-type' : 'application/json' ,
280
- }
281
-
282
- if self .__auth_header is not None :
283
- headers ['Authorization' ] = self .__auth_header
284
-
285
- self .__conn .request ('POST' , self .__url .path , postdata , headers )
280
+ self .__conn .request ('POST' , self .__url .path , postdata , self ._headers )
286
281
return self ._get_response ()
287
282
288
283
def _get_response (self ):
0 commit comments