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/flip_server/mem_cache.h" | 5 #include "net/tools/flip_server/mem_cache.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 size_t pos = 0; | 153 size_t pos = 0; |
154 size_t old_pos = 0; | 154 size_t old_pos = 0; |
155 while (true) { | 155 while (true) { |
156 old_pos = pos; | 156 old_pos = pos; |
157 pos += framer.ProcessInput(filename_contents.data() + pos, | 157 pos += framer.ProcessInput(filename_contents.data() + pos, |
158 filename_contents.size() - pos); | 158 filename_contents.size() - pos); |
159 if (framer.Error() || pos == old_pos) { | 159 if (framer.Error() || pos == old_pos) { |
160 LOG(ERROR) << "Unable to make forward progress, or error" | 160 LOG(ERROR) << "Unable to make forward progress, or error" |
161 " framing file: " << filename; | 161 " framing file: " << filename; |
162 if (framer.Error()) { | 162 if (framer.Error()) { |
163 LOG(INFO) << "********************************************ERROR!"; | 163 VLOG(0) << "********************************************ERROR!"; |
164 return; | 164 return; |
165 } | 165 } |
166 return; | 166 return; |
167 } | 167 } |
168 if (framer.MessageFullyRead()) { | 168 if (framer.MessageFullyRead()) { |
169 // If no Content-Length or Transfer-Encoding was captured in the | 169 // If no Content-Length or Transfer-Encoding was captured in the |
170 // file, then the rest of the data is the body. Many of the captures | 170 // file, then the rest of the data is the body. Many of the captures |
171 // from within Chrome don't have content-lengths. | 171 // from within Chrome don't have content-lengths. |
172 if (!visitor.body.length()) | 172 if (!visitor.body.length()) |
173 visitor.body = filename_contents.substr(pos); | 173 visitor.body = filename_contents.substr(pos); |
(...skipping 15 matching lines...) Expand all Loading... |
189 if (visitor.headers.HasHeader("expires")) { | 189 if (visitor.headers.HasHeader("expires")) { |
190 visitor.headers.RemoveAllOfHeader("expires"); | 190 visitor.headers.RemoveAllOfHeader("expires"); |
191 visitor.headers.AppendHeader("expires", | 191 visitor.headers.AppendHeader("expires", |
192 "Fri, 30 Aug, 2019 12:00:00 GMT"); | 192 "Fri, 30 Aug, 2019 12:00:00 GMT"); |
193 } | 193 } |
194 #endif | 194 #endif |
195 DCHECK_GE(std::string(filename).size(), cwd_.size() + 1); | 195 DCHECK_GE(std::string(filename).size(), cwd_.size() + 1); |
196 DCHECK_EQ(std::string(filename).substr(0, cwd_.size()), cwd_); | 196 DCHECK_EQ(std::string(filename).substr(0, cwd_.size()), cwd_); |
197 DCHECK_EQ(filename[cwd_.size()], '/'); | 197 DCHECK_EQ(filename[cwd_.size()], '/'); |
198 std::string filename_stripped = std::string(filename).substr(cwd_.size() + 1); | 198 std::string filename_stripped = std::string(filename).substr(cwd_.size() + 1); |
199 LOG(INFO) << "Adding file (" << visitor.body.length() << " bytes): " | 199 VLOG(0) << "Adding file (" << visitor.body.length() << " bytes): " |
200 << filename_stripped; | 200 << filename_stripped; |
201 size_t slash_pos = filename_stripped.find('/'); | 201 size_t slash_pos = filename_stripped.find('/'); |
202 if (slash_pos == std::string::npos) { | 202 if (slash_pos == std::string::npos) { |
203 slash_pos = filename_stripped.size(); | 203 slash_pos = filename_stripped.size(); |
204 } | 204 } |
205 InsertFile(&visitor.headers, | 205 InsertFile(&visitor.headers, |
206 filename_stripped.substr(0, slash_pos), | 206 filename_stripped.substr(0, slash_pos), |
207 visitor.body); | 207 visitor.body); |
208 } | 208 } |
209 | 209 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 void MemoryCache::ClearFiles() { | 250 void MemoryCache::ClearFiles() { |
251 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { | 251 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { |
252 delete i->second; | 252 delete i->second; |
253 } | 253 } |
254 files_.clear(); | 254 files_.clear(); |
255 } | 255 } |
256 | 256 |
257 } // namespace net | 257 } // namespace net |
OLD | NEW |