From 669f3ea7641ca8e77cf059c7587136a6317c52a4 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 13 Jun 2014 00:01:58 +0400 Subject: [PATCH] Handle HTTP Error 303 redirects --- Robots/bkmk_rurllib.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index a2174a8..2fdec0e 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -17,8 +17,8 @@ from Robots.bkmk_robot_base import robot_base, RedirectException, get_error class MyURLopener(urllib.URLopener): - # Error 302 -- relocated (temporarily) - def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): + # Error 301 -- relocated (temporarily) + def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): @@ -27,10 +27,12 @@ class MyURLopener(urllib.URLopener): newurl = "Nowhere" raise RedirectException(errcode, newurl) - # Error 301 -- also relocated (permanently) - http_error_301 = http_error_302 + # Error 302 -- also relocated (permanently) + http_error_302 = http_error_301 + # Error 303 -- also relocated (permanently) + http_error_303 = http_error_301 # Error 307 -- also relocated (temporary) - http_error_307 = http_error_302 + http_error_307 = http_error_301 # Error 401 -- authentication required def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): -- 2.39.5