Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: content/browser/download/download_manager_impl.cc

Issue 1444253003: Use If-Range instead of If-Match/If-Unmodified-Since for partial requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make it obvious that the interrupt reason is obsolete. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_manager_impl.cc
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 7562c0f3619b30e5e4e6ea0aa4dfc9c50570710f..9d87c3bb8e9ce14da5a06ddad2ab9780814273c3 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -89,20 +89,21 @@ void BeginDownload(scoped_ptr<DownloadUrlParameters> params,
// We shouldn't be asked to continue if we don't have a verifier.
DCHECK(params->offset() == 0 || has_etag || has_last_modified);
- if (params->offset() > 0) {
+ if (params->offset() > 0 && (has_etag || has_last_modified)) {
request->SetExtraRequestHeaderByName(
"Range",
base::StringPrintf("bytes=%" PRId64 "-", params->offset()),
true);
- if (has_last_modified) {
- request->SetExtraRequestHeaderByName("If-Unmodified-Since",
- params->last_modified(),
- true);
- }
- if (has_etag) {
- request->SetExtraRequestHeaderByName("If-Match", params->etag(), true);
- }
+ // In accordance with RFC 2616 Section 14.27, use If-Range to specify that
+ // the server return the entire entity if the validator doesn't match.
+ // Last-Modified can be used in the absence of ETag as a validator if the
+ // response headers satisfied the HttpUtil::HasStrongValidators() predicate.
+ //
+ // This function assumes that HasStrongValidators() was true and that the
+ // ETag and Last-Modified header values supplied are valid.
+ request->SetExtraRequestHeaderByName(
+ "If-Range", has_etag ? params->etag() : params->last_modified(), true);
}
for (DownloadUrlParameters::RequestHeadersType::const_iterator iter

Powered by Google App Engine
This is Rietveld 408576698