| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tools/dump_cache/cache_dumper.h" | 5 #include "net/tools/dump_cache/cache_dumper.h" |
| 6 | 6 |
| 7 #include "net/base/io_buffer.h" | 7 #include "net/base/io_buffer.h" |
| 8 #include "net/disk_cache/entry_impl.h" | 8 #include "net/disk_cache/entry_impl.h" |
| 9 #include "net/http/http_cache.h" | 9 #include "net/http/http_cache.h" |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool DiskDumper::WriteEntry(disk_cache::Entry* entry, int index, int offset, | 132 bool DiskDumper::WriteEntry(disk_cache::Entry* entry, int index, int offset, |
| 133 net::IOBuffer* buf, int buf_len) { | 133 net::IOBuffer* buf, int buf_len) { |
| 134 if (!entry_) | 134 if (!entry_) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 std::string headers; | 137 std::string headers; |
| 138 const char *data; | 138 const char *data; |
| 139 int len; | 139 int len; |
| 140 if (index == 0) { // Stream 0 is the headers. | 140 if (index == 0) { // Stream 0 is the headers. |
| 141 net::HttpResponseInfo response_info; | 141 net::HttpResponseInfo response_info; |
| 142 bool truncated; |
| 142 if (!net::HttpCache::ParseResponseInfo(buf->data(), buf_len, | 143 if (!net::HttpCache::ParseResponseInfo(buf->data(), buf_len, |
| 143 &response_info)) | 144 &response_info, &truncated)) |
| 144 return false; | 145 return false; |
| 145 | 146 |
| 147 // Skip this entry if it was truncated (results in an empty file). |
| 148 if (truncated) |
| 149 return true; |
| 150 |
| 146 // Remove the size headers. | 151 // Remove the size headers. |
| 147 response_info.headers->RemoveHeader("transfer-encoding"); | 152 response_info.headers->RemoveHeader("transfer-encoding"); |
| 148 response_info.headers->RemoveHeader("content-length"); | 153 response_info.headers->RemoveHeader("content-length"); |
| 149 response_info.headers->RemoveHeader("x-original-url"); | 154 response_info.headers->RemoveHeader("x-original-url"); |
| 150 | 155 |
| 151 // Convert the headers into a string ending with LF. | 156 // Convert the headers into a string ending with LF. |
| 152 GetNormalizedHeaders(response_info, &headers); | 157 GetNormalizedHeaders(response_info, &headers); |
| 153 | 158 |
| 154 // Append a header for the original URL. | 159 // Append a header for the original URL. |
| 155 std::string url = entry_url_; | 160 std::string url = entry_url_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 181 | 186 |
| 182 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 187 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 183 base::Time last_modified) { | 188 base::Time last_modified) { |
| 184 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 189 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 185 CloseHandle(entry_); | 190 CloseHandle(entry_); |
| 186 #else | 191 #else |
| 187 file_util::CloseFile(entry_); | 192 file_util::CloseFile(entry_); |
| 188 #endif | 193 #endif |
| 189 } | 194 } |
| 190 | 195 |
| OLD | NEW |