1
0
Fork 0

terrasync.py: make HTTPGetter.get() return the HTTPGetCallback.callback ret value

This way, the caller can get access to interesting things from the
callback, such as the HTTPResponse object (wrapper for the socket).
This commit is contained in:
Florent Rougon 2018-01-26 13:23:42 +01:00
parent b7fc63d896
commit de4291b851

View file

@ -49,20 +49,24 @@ class HTTPGetter:
def doGet(self, httpGetCallback):
conn = self.httpConnection
request = httpGetCallback
self.httpConnection.request("GET", self.parsedBaseUrl.path + request.src, None, self.httpRequestHeaders)
self.httpConnection.request("GET",
self.parsedBaseUrl.path + request.src,
None, self.httpRequestHeaders)
httpGetCallback.result = self.httpConnection.getresponse()
httpGetCallback.callback()
return httpGetCallback.callback()
def get(self, httpGetCallback):
try:
self.doGet(httpGetCallback)
res = self.doGet(httpGetCallback)
except HTTPException:
# try to reconnect once
#print("reconnect")
self.httpConnection.close()
self.httpConnection.connect()
self.doGet(httpGetCallback)
res = self.doGet(httpGetCallback)
return res
#################################################################################################################################