Index: content/browser/download/download_request_core.cc |
diff --git a/content/browser/download/download_request_core.cc b/content/browser/download/download_request_core.cc |
index 511ebb4f36114b37e86a6d914d5e48bf7fc8a0b4..285771606cd1951582f7c18509c830639b53a0ed 100644 |
--- a/content/browser/download/download_request_core.cc |
+++ b/content/browser/download/download_request_core.cc |
@@ -199,6 +199,7 @@ DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, |
bytes_read_(0), |
pause_count_(0), |
was_deferred_(false), |
+ is_partial_request_(false), |
started_(false), |
abort_reason_(DOWNLOAD_INTERRUPT_REASON_NONE) { |
DCHECK(request_); |
@@ -213,6 +214,7 @@ DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, |
download_id_ = request_data->download_id(); |
on_started_callback_ = request_data->callback(); |
DownloadRequestData::Detach(request_); |
+ is_partial_request_ = save_info_->offset > 0; |
} else { |
save_info_.reset(new DownloadSaveInfo); |
} |
@@ -332,6 +334,18 @@ bool DownloadRequestCore::OnResponseStarted( |
return true; |
} |
+bool DownloadRequestCore::OnRequestRedirected() { |
+ DVLOG(20) << __FUNCTION__ << "() " << DebugString(); |
+ if (is_partial_request_) { |
+ // A redirect while attempting a partial resumption indicates a potential |
+ // middle box. Trigger another interruption so that the DownloadItem can |
+ // retry. |
+ abort_reason_ = DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE; |
+ return false; |
+ } |
+ return true; |
+} |
+ |
// Create a new buffer, which will be handed to the download thread for file |
// writing and deletion. |
bool DownloadRequestCore::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
@@ -388,6 +402,12 @@ bool DownloadRequestCore::OnReadCompleted(int bytes_read, bool* defer) { |
return true; |
} |
+void DownloadRequestCore::OnWillAbort(DownloadInterruptReason reason) { |
+ DVLOG(20) << __FUNCTION__ << "() reason=" << reason << " " << DebugString(); |
+ DCHECK(!started_); |
+ abort_reason_ = reason; |
+} |
+ |
void DownloadRequestCore::OnResponseCompleted( |
const net::URLRequestStatus& status) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |