Retry with truncated URL on error 500 in HTTP response.

This commit is contained in:
Arun Prakash Jana 2016-04-09 19:13:12 +05:30
parent 056a83f013
commit d7b0f2483b
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB

10
buku
View File

@ -271,6 +271,7 @@ def fetchTitle(url):
global titleData global titleData
titleData = None titleData = None
urlconn = None urlconn = None
retry = False
try: try:
urlconn, resp = getPageResp(url, False) urlconn, resp = getPageResp(url, False)
@ -301,6 +302,15 @@ def fetchTitle(url):
url = redirurl url = redirurl
urlconn.close() urlconn.close()
urlconn, resp = getPageResp(url, True) urlconn, resp = getPageResp(url, True)
if resp.status == 500 and retry == False:
"""Retry on status 500 (Internal Server Error) with truncated
URL. Some servers support truncated request URL on redirection.
"""
urlconn.close()
if debug:
print("Received status 500: retrying.")
urlconn, resp = getPageResp(url, False)
retry = True
else: else:
printmsg(("[" + str(resp.status) + "] " + resp.reason), "ERROR") printmsg(("[" + str(resp.status) + "] " + resp.reason), "ERROR")
break break