Merge pull request #381 from JackDandy/feature/ChangeHTTPErrorHandler

Change handling of general HTTP error response codes to prevent issues.
This commit is contained in:
JackDandy 2015-06-04 11:07:32 +01:00
commit 0ed990d369
3 changed files with 17 additions and 4 deletions

View file

@ -16,6 +16,8 @@
* Change provider SCC remove 1 of 3 requests per search to save 30% time
* Change provider Womble's use SSL
* Fix getManualSearchStatus: object has no attribute 'segment'
* Change handling of general HTTP error response codes to prevent issues
* Add handling for CloudFlare custom HTTP response codes
### 0.9.1 (2015-05-25 03:03:00 UTC)
@ -84,7 +86,7 @@
* Change disable the Force buttons on the Manage Searches page while a search is running
* Change staggered periods of testing and updating of all shows "ended" status up to 460 days
* Change "Archive" to "Upgrade to" in Edit show and other places and improve related texts for clarity
* Fix history consolidation to only update an episode status if the history disagrees with the status.
* Fix history consolidation to only update an episode status if the history disagrees with the status
### 0.8.3 (2015-04-25 08:48:00 UTC)

View file

@ -36,6 +36,7 @@ http_error_code = {
304: 'Not Modified',
305: 'Use Proxy',
307: 'Temporary Redirect',
308: 'Permanent Redirect',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
@ -54,13 +55,17 @@ http_error_code = {
415: 'Unsupported Media Type',
416: 'Requested Range Not Satisfiable',
417: 'Expectation Failed',
429: 'Too Many Requests',
431: 'Request Header Fields Too Large',
444: 'No Response',
451: 'Unavailable For Legal Reasons',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
524: 'Request to host timedout waiting for reply back'
511: 'Network Authentication Required',
}
default_host = {'utorrent': 'http://localhost:8000',

View file

@ -1154,8 +1154,14 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
resp = session.get(url, timeout=timeout)
if not resp.ok:
logger.log(u"Requested url " + url + " returned status code is " + str(
resp.status_code) + ': ' + clients.http_error_code[resp.status_code], logger.DEBUG)
if resp.status_code in clients.http_error_code:
http_err_text = clients.http_error_code[resp.status_code]
elif resp.status_code in range(520, 527):
http_err_text = 'CloudFlare to origin server connection failure'
else:
http_err_text = 'Custom HTTP error code'
logger.log(u'Requested url %s returned status code is %s: %s'
% (url, resp.status_code, http_err_text), logger.DEBUG)
return
except requests.exceptions.HTTPError, e: