| 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/tools/quic/quic_in_memory_cache.h" | 5 #include "net/tools/quic/quic_in_memory_cache.h" |
| 6 | 6 |
| 7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 string raw_headers = | 114 string raw_headers = |
| 115 HttpUtil::AssembleRawHeaders(file_contents.data(), headers_end); | 115 HttpUtil::AssembleRawHeaders(file_contents.data(), headers_end); |
| 116 | 116 |
| 117 scoped_refptr<HttpResponseHeaders> response_headers = | 117 scoped_refptr<HttpResponseHeaders> response_headers = |
| 118 new HttpResponseHeaders(raw_headers); | 118 new HttpResponseHeaders(raw_headers); |
| 119 | 119 |
| 120 string base; | 120 string base; |
| 121 if (response_headers->GetNormalizedHeader("X-Original-Url", &base)) { | 121 if (response_headers->GetNormalizedHeader("X-Original-Url", &base)) { |
| 122 response_headers->RemoveHeader("X-Original-Url"); | 122 response_headers->RemoveHeader("X-Original-Url"); |
| 123 // Remove the protocol so we can add it below. | 123 // Remove the protocol so we can add it below. |
| 124 if (StartsWithASCII(base, "https://", false)) { | 124 if (base::StartsWithASCII(base, "https://", false)) { |
| 125 base = base.substr(8); | 125 base = base.substr(8); |
| 126 } else if (StartsWithASCII(base, "http://", false)) { | 126 } else if (base::StartsWithASCII(base, "http://", false)) { |
| 127 base = base.substr(7); | 127 base = base.substr(7); |
| 128 } | 128 } |
| 129 } else { | 129 } else { |
| 130 base = file; | 130 base = file; |
| 131 } | 131 } |
| 132 | 132 |
| 133 size_t path_start = base.find_first_of('/'); | 133 size_t path_start = base.find_first_of('/'); |
| 134 StringPiece host(StringPiece(base).substr(0, path_start)); | 134 StringPiece host(StringPiece(base).substr(0, path_start)); |
| 135 StringPiece path(StringPiece(base).substr(path_start)); | 135 StringPiece path(StringPiece(base).substr(path_start)); |
| 136 if (path[path.length() - 1] == ',') { | 136 if (path[path.length() - 1] == ',') { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 new_response->set_body(response_body); | 172 new_response->set_body(response_body); |
| 173 responses_[key] = new_response; | 173 responses_[key] = new_response; |
| 174 } | 174 } |
| 175 | 175 |
| 176 string QuicInMemoryCache::GetKey(StringPiece host, StringPiece path) const { | 176 string QuicInMemoryCache::GetKey(StringPiece host, StringPiece path) const { |
| 177 return host.as_string() + path.as_string(); | 177 return host.as_string() + path.as_string(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace tools | 180 } // namespace tools |
| 181 } // namespace net | 181 } // namespace net |
| OLD | NEW |