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

Unified Diff: net/http/http_cache_transaction.cc

Issue 6588105: Http cache: Fix handling of truncated entries.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 months 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
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
===================================================================
--- net/http/http_cache_transaction.cc (revision 75777)
+++ net/http/http_cache_transaction.cc (working copy)
@@ -731,6 +731,11 @@
if (!cache_)
return ERR_UNEXPECTED;
+ // If there is an error and we are saving the data, just tell the user about
+ // it and wait until the destructor runs to see if we can keep the data.
+ if (mode_ != NONE && result < 0)
+ return result;
+
next_state_ = STATE_CACHE_WRITE_DATA;
return result;
}
@@ -982,6 +987,16 @@
// We no longer need the network transaction, so destroy it.
final_upload_progress_ = network_trans_->GetUploadProgress();
network_trans_.reset();
+ } else if (entry_ && server_responded_206_ && truncated_ &&
+ partial_->initial_validation()) {
+ // We just finishing the validation of a truncated entry, and the server
eroman 2011/03/02 02:06:04 wording nit: "finishing" --> "finished".
+ // is willing to resume the operation. Now we go back and start serving
+ // the first part to the user.
+ network_trans_.reset();
+ new_response_ = NULL;
+ next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION;
+ partial_->SetRangeToStartDownload();
+ return OK;
}
next_state_ = STATE_OVERWRITE_CACHED_RESPONSE;
return OK;
@@ -1442,6 +1457,9 @@
bool skip_validation = effective_load_flags_ & LOAD_PREFERRING_CACHE ||
!RequiresValidation();
+ if (truncated_)
+ skip_validation = !partial_->initial_validation();
+
if ((partial_.get() && !partial_->IsCurrentRangeCached()) || invalid_range_)
skip_validation = false;
@@ -1738,8 +1756,16 @@
// 304 is not expected here, but we'll spare the entry (unless it was
// truncated).
- if (truncated_)
+ if (truncated_) {
+ if (!reading_ && response_code == 200) {
+ // The server is sending the whole resource, and we can save it.
+ DCHECK(!partial_->IsLastRange());
+ partial_.reset();
+ truncated_ = false;
+ return true;
+ }
failure = true;
+ }
}
if (failure) {
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698