summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/http/http_cache.cc1
-rw-r--r--net/http/http_cache_unittest.cc35
-rw-r--r--net/http/partial_data.cc2
3 files changed, 36 insertions, 2 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index be9dc48..855c7e8 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -945,7 +945,6 @@ int HttpCache::Transaction::BeginPartialCacheValidation() {
if (!custom_request_.get()) {
custom_request_.reset(new HttpRequestInfo(*request_));
request_ = custom_request_.get();
- DCHECK(custom_request_->extra_headers.empty());
}
}
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index a72c36d..674d8fd 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1995,6 +1995,41 @@ TEST(HttpCache, GET_Previous206) {
RemoveMockTransaction(&kRangeGET_TransactionOK);
}
+// Tests that we can handle non-range requests when we have cached the first
+// part of the object and server replies with 304 (Not Modified).
+TEST(HttpCache, GET_Previous206_NotModified) {
+ MockHttpCache cache;
+ cache.http_cache()->set_enable_range_support(true);
+
+ MockTransaction transaction(kRangeGET_TransactionOK);
+ transaction.request_headers = "Range: bytes = 0-9\r\n";
+ transaction.data = "rg: 00-09 ";
+ AddMockTransaction(&transaction);
+ std::string headers;
+
+ // Write to the cache (0-9).
+ RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers);
+
+ EXPECT_TRUE(Verify206Response(headers, 0, 9));
+ EXPECT_EQ(1, cache.network_layer()->transaction_count());
+ EXPECT_EQ(0, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+
+ // Read from the cache (0-9), write and read from cache (10 - 79),
+ MockTransaction transaction2(kRangeGET_TransactionOK);
+ transaction2.request_headers = "Foo: bar\r\n";
+ transaction2.data = "rg: 00-09 rg: 10-19 rg: 20-29 rg: 30-39 rg: 40-49 "
+ "rg: 50-59 rg: 60-69 rg: 70-79 ";
+ RunTransactionTestWithResponse(cache.http_cache(), transaction2, &headers);
+
+ EXPECT_EQ(0U, headers.find("HTTP/1.1 200 OK\n"));
+ EXPECT_EQ(3, cache.network_layer()->transaction_count());
+ EXPECT_EQ(1, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
+
+ RemoveMockTransaction(&transaction);
+}
+
// Tests that we can handle cached 206 responses that are not sparse.
TEST(HttpCache, GET_Previous206_NotSparse) {
MockHttpCache cache;
diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc
index fcd7808..1b4b575 100644
--- a/net/http/partial_data.cc
+++ b/net/http/partial_data.cc
@@ -179,7 +179,7 @@ bool PartialData::IsRequestedRangeOK() {
bool PartialData::ResponseHeadersOK(const HttpResponseHeaders* headers) {
if (headers->response_code() == 304) {
- if (truncated_)
+ if (!byte_range_.IsValid() || truncated_)
return true;
// We must have a complete range here.