@@ -224,14 +224,8 @@ def __init__(self,
224
224
self .__conn = httplib .HTTPConnection (self .__url .hostname , port = port ,
225
225
timeout = timeout )
226
226
227
- def _call (self , service_name , * args ):
228
- self .__id_count += 1
229
-
230
- postdata = json .dumps ({'version' : '1.1' ,
231
- 'method' : service_name ,
232
- 'params' : args ,
233
- 'id' : self .__id_count })
234
-
227
+ @property
228
+ def _headers (self ):
235
229
headers = {
236
230
'Host' : self .__url .hostname ,
237
231
'User-Agent' : DEFAULT_USER_AGENT ,
@@ -241,7 +235,18 @@ def _call(self, service_name, *args):
241
235
if self .__auth_header is not None :
242
236
headers ['Authorization' ] = self .__auth_header
243
237
244
- self .__conn .request ('POST' , self .__url .path , postdata , headers )
238
+ return headers
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
+
248
+
249
+ self .__conn .request ('POST' , self .__url .path , postdata , self ._headers )
245
250
246
251
response = self ._get_response ()
247
252
err = response .get ('error' )
@@ -259,17 +264,7 @@ def _call(self, service_name, *args):
259
264
260
265
def _batch (self , rpc_call_list ):
261
266
postdata = json .dumps (list (rpc_call_list ))
262
-
263
- headers = {
264
- 'Host' : self .__url .hostname ,
265
- 'User-Agent' : DEFAULT_USER_AGENT ,
266
- 'Content-type' : 'application/json' ,
267
- }
268
-
269
- if self .__auth_header is not None :
270
- headers ['Authorization' ] = self .__auth_header
271
-
272
- self .__conn .request ('POST' , self .__url .path , postdata , headers )
267
+ self .__conn .request ('POST' , self .__url .path , postdata , self ._headers )
273
268
return self ._get_response ()
274
269
275
270
def _get_response (self ):
0 commit comments