| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_cache_transaction.h" | 5 #include "net/http/http_cache_transaction.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 response_ = *new_response_; | 1552 response_ = *new_response_; |
| 1553 | 1553 |
| 1554 if (request_->method == "HEAD") { | 1554 if (request_->method == "HEAD") { |
| 1555 // This response is replacing the cached one. | 1555 // This response is replacing the cached one. |
| 1556 DoneWritingToEntry(false); | 1556 DoneWritingToEntry(false); |
| 1557 mode_ = NONE; | 1557 mode_ = NONE; |
| 1558 new_response_ = NULL; | 1558 new_response_ = NULL; |
| 1559 return OK; | 1559 return OK; |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 if (handling_206_ && !CanResume(false)) { | |
| 1563 // There is no point in storing this resource because it will never be used. | |
| 1564 DoneWritingToEntry(false); | |
| 1565 if (partial_.get()) | |
| 1566 partial_->FixResponseHeaders(response_.headers.get(), true); | |
| 1567 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; | |
| 1568 return OK; | |
| 1569 } | |
| 1570 | |
| 1571 target_state_ = STATE_TRUNCATE_CACHED_DATA; | 1562 target_state_ = STATE_TRUNCATE_CACHED_DATA; |
| 1572 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : | 1563 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : |
| 1573 STATE_CACHE_WRITE_RESPONSE; | 1564 STATE_CACHE_WRITE_RESPONSE; |
| 1574 return OK; | 1565 return OK; |
| 1575 } | 1566 } |
| 1576 | 1567 |
| 1577 int HttpCache::Transaction::DoTruncateCachedData() { | 1568 int HttpCache::Transaction::DoTruncateCachedData() { |
| 1578 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; | 1569 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; |
| 1579 if (!entry_) | 1570 if (!entry_) |
| 1580 return OK; | 1571 return OK; |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2300 | 2291 |
| 2301 if (request_->method == "PUT" || request_->method == "DELETE") | 2292 if (request_->method == "PUT" || request_->method == "DELETE") |
| 2302 return false; | 2293 return false; |
| 2303 | 2294 |
| 2304 // This only makes sense for cached 200 or 206 responses. | 2295 // This only makes sense for cached 200 or 206 responses. |
| 2305 if (response_.headers->response_code() != 200 && | 2296 if (response_.headers->response_code() != 200 && |
| 2306 response_.headers->response_code() != 206) { | 2297 response_.headers->response_code() != 206) { |
| 2307 return false; | 2298 return false; |
| 2308 } | 2299 } |
| 2309 | 2300 |
| 2310 // We should have handled this case before. | 2301 if (response_.headers->response_code() == 206 && |
| 2311 DCHECK(response_.headers->response_code() != 206 || | 2302 !response_.headers->HasStrongValidators()) { |
| 2312 response_.headers->HasStrongValidators()); | 2303 return false; |
| 2304 } |
| 2313 | 2305 |
| 2314 // Just use the first available ETag and/or Last-Modified header value. | 2306 // Just use the first available ETag and/or Last-Modified header value. |
| 2315 // TODO(darin): Or should we use the last? | 2307 // TODO(darin): Or should we use the last? |
| 2316 | 2308 |
| 2317 std::string etag_value; | 2309 std::string etag_value; |
| 2318 if (response_.headers->GetHttpVersion() >= HttpVersion(1, 1)) | 2310 if (response_.headers->GetHttpVersion() >= HttpVersion(1, 1)) |
| 2319 response_.headers->EnumerateHeader(NULL, "etag", &etag_value); | 2311 response_.headers->EnumerateHeader(NULL, "etag", &etag_value); |
| 2320 | 2312 |
| 2321 std::string last_modified_value; | 2313 std::string last_modified_value; |
| 2322 if (!vary_mismatch_) { | 2314 if (!vary_mismatch_) { |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2862 default: | 2854 default: |
| 2863 NOTREACHED(); | 2855 NOTREACHED(); |
| 2864 } | 2856 } |
| 2865 } | 2857 } |
| 2866 | 2858 |
| 2867 void HttpCache::Transaction::OnIOComplete(int result) { | 2859 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2868 DoLoop(result); | 2860 DoLoop(result); |
| 2869 } | 2861 } |
| 2870 | 2862 |
| 2871 } // namespace net | 2863 } // namespace net |
| OLD | NEW |