@@ -224,14 +224,8 @@ def __init__(self,
224224 self .__conn = httplib .HTTPConnection (self .__url .hostname , port = port ,
225225 timeout = timeout )
226226
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 ):
235229 headers = {
236230 'Host' : self .__url .hostname ,
237231 'User-Agent' : DEFAULT_USER_AGENT ,
@@ -241,7 +235,18 @@ def _call(self, service_name, *args):
241235 if self .__auth_header is not None :
242236 headers ['Authorization' ] = self .__auth_header
243237
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 )
245250
246251 response = self ._get_response ()
247252 err = response .get ('error' )
@@ -259,17 +264,7 @@ def _call(self, service_name, *args):
259264
260265 def _batch (self , rpc_call_list ):
261266 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 )
273268 return self ._get_response ()
274269
275270 def _get_response (self ):
0 commit comments