diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 23:27:36 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 23:27:36 +0000 |
commit | c85316f83dc5d24b593fc9d082375bfb7dc49260 (patch) | |
tree | 613350680ffea3ba7a9b066fa753b152b95b0f06 /net/http/http_cache_transaction.cc | |
parent | e1d16eb9348270bb806f9b9622b84d0df842e2e4 (diff) | |
download | chromium_src-c85316f83dc5d24b593fc9d082375bfb7dc49260.zip chromium_src-c85316f83dc5d24b593fc9d082375bfb7dc49260.tar.gz chromium_src-c85316f83dc5d24b593fc9d082375bfb7dc49260.tar.bz2 |
Http Cache: Detect Content_length mismatches and mark entries as
truncated when we do.
BUG=92944
TEST=net_unittests
Review URL: http://codereview.chromium.org/7650026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_transaction.cc')
-rw-r--r-- | net/http/http_cache_transaction.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 4b51cd5..9b3b6e8 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -1369,7 +1369,8 @@ int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { result = write_len_; } else if (!done_reading_ && entry_) { int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex); - if (response_.headers->GetContentLength() == current_size) + int64 body_size = response_.headers->GetContentLength(); + if (body_size >= 0 && body_size <= current_size) done_reading_ = true; } @@ -1380,8 +1381,13 @@ int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { return DoPartialNetworkReadCompleted(result); } - if (result == 0) // End of file. - DoneWritingToEntry(true); + if (result == 0) { + // End of file. This may be the result of a connection problem so see if we + // have to keep the entry around to be flagged as truncated later on. + if (done_reading_ || !entry_ || partial_.get() || + response_.headers->GetContentLength() <= 0) + DoneWritingToEntry(true); + } return result; } |