expose allowed_status tuple for media pipeline

This commit is contained in:
Bernardas 2016-08-24 08:39:30 +00:00 committed by Paul Tremberth
parent 2e052c8615
commit f0b4077f81
1 changed files with 3 additions and 2 deletions

View File

@ -57,6 +57,8 @@ class RedirectMiddleware(BaseRedirectMiddleware):
Handle redirection of requests based on response status
and meta-refresh html tag.
"""
allowed_status = (301, 302, 303, 307)
def process_response(self, request, response, spider):
if (request.meta.get('dont_redirect', False) or
response.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 response
location = safe_url_string(response.headers['location'])