Scrapy, a fast high-level web crawling & scraping framework for Python.
expose allowed_status tuple for media pipeline
Bernardasf0b4077f8126
diff --git a/scrapy/downloadermiddlewares/redirect.py b/scrapy/downloadermiddlewares/redirect.pyindex 26677e527..ae4ad8891 100644--- a/scrapy/downloadermiddlewares/redirect.py+++ b/scrapy/downloadermiddlewares/redirect.py@@ -57,6 +57,8 @@ class RedirectMiddleware(BaseRedirectMiddleware):Handle redirection of requests based on response statusand meta-refresh html tag."""+ allowed_status = (301, 302, 303, 307)+def process_response(self, request, response, spider):if (request.meta.get('dont_redirect', False) orresponse.status in getattr(spider, 'handle_httpstatus_list', []) or@@ -64,8 +66,7 @@ class RedirectMiddleware(BaseRedirectMiddleware):request.meta.get('handle_httpstatus_all', False)):return response- allowed_status = (301, 302, 303, 307)- if 'Location' not in response.headers or response.status not in allowed_status:+ if 'Location' not in response.headers or response.status not in self.allowed_status:return responselocation = safe_url_string(response.headers['location'])