<p dir="auto">hi</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="when i setting file_urls &quot;http://m.baidu.com/api?action=redirect&amp;token=kpyysd&amp;from=1014090y&amp;type=app&amp;dltype=new&amp;refid=2650327114&amp;tj=soft_5845028_88031597_%E8%AF%AD%E9%9F%B3%E6%90%9C%E7%B4%A2&amp;refp=action_search&amp;blink=da5b687474703a2f2f7265736765742e39312e636f6d2f536f66742f436f6e74726f6c6c65722e617368783f616374696f6e3d646f776e6c6f61642674706c3d312669643d34313034393931c658&amp;crversion=1&quot;"><pre class="notranslate"><code class="notranslate">when i setting file_urls "http://m.baidu.com/api?action=redirect&amp;token=kpyysd&amp;from=1014090y&amp;type=app&amp;dltype=new&amp;refid=2650327114&amp;tj=soft_5845028_88031597_%E8%AF%AD%E9%9F%B3%E6%90%9C%E7%B4%A2&amp;refp=action_search&amp;blink=da5b687474703a2f2f7265736765742e39312e636f6d2f536f66742f436f6e74726f6c6c65722e617368783f616374696f6e3d646f776e6c6f61642674706c3d312669643d34313034393931c658&amp;crversion=1"
</code></pre></div>
<p dir="auto">this url redirect 3  times so when i use scrap download it  the scrapy retrun 302  how can i setting  it can working ? please help me!<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/3350372/23991950/1795e90a-0a76-11e7-9b19-4128bfdb3914.png"><img src="https://cloud.githubusercontent.com/assets/3350372/23991950/1795e90a-0a76-11e7-9b19-4128bfdb3914.png" alt="qq 20170316182328" style="max-width: 100%;"></a></p>
<p dir="auto">Basically, what's happened is that my spider is unable to download the files because the file_urls provided are actually redirected to the final download link. However, because of the following code, the redirect download middleware is effectively disabled, which makes the download fail.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def _check_media_to_download(self, result, request, info):
        if result is not None:
            return result
        if self.download_func:
            # this ugly code was left only to support tests. TODO: remove
            dfd = mustbe_deferred(self.download_func, request, info.spider)
            dfd.addCallbacks(
                callback=self.media_downloaded, callbackArgs=(request, info),
                errback=self.media_failed, errbackArgs=(request, info))
        else:
            request.meta['handle_httpstatus_all'] = True
            dfd = self.crawler.engine.download(request, info.spider)
            dfd.addCallbacks(
                callback=self.media_downloaded, callbackArgs=(request, info),
                errback=self.media_failed, errbackArgs=(request, info))
        return dfd"><pre class="notranslate"><code class="notranslate">def _check_media_to_download(self, result, request, info):
        if result is not None:
            return result
        if self.download_func:
            # this ugly code was left only to support tests. TODO: remove
            dfd = mustbe_deferred(self.download_func, request, info.spider)
            dfd.addCallbacks(
                callback=self.media_downloaded, callbackArgs=(request, info),
                errback=self.media_failed, errbackArgs=(request, info))
        else:
            request.meta['handle_httpstatus_all'] = True
            dfd = self.crawler.engine.download(request, info.spider)
            dfd.addCallbacks(
                callback=self.media_downloaded, callbackArgs=(request, info),
                errback=self.media_failed, errbackArgs=(request, info))
        return dfd
</code></pre></div>
<p dir="auto">And here is the check in the redirect middleware that disables it:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (request.meta.get('dont_redirect', False) or
                response.status in getattr(spider, 'handle_httpstatus_list', []) or
                response.status in request.meta.get('handle_httpstatus_list', []) or
                request.meta.get('handle_httpstatus_all', False)):
            return response
"><pre class="notranslate"><code class="notranslate">if (request.meta.get('dont_redirect', False) or
                response.status in getattr(spider, 'handle_httpstatus_list', []) or
                response.status in request.meta.get('handle_httpstatus_list', []) or
                request.meta.get('handle_httpstatus_all', False)):
            return response

</code></pre></div>
<p dir="auto">My question is: What is the point of enabling the handling of httpstatus_all, when it effectively disables all of the checks?</p>