| 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_vary_data.h" | 5 #include "net/http/http_vary_data.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 void HttpVaryData::Persist(base::Pickle* pickle) const { | 61 void HttpVaryData::Persist(base::Pickle* pickle) const { |
| 62 DCHECK(is_valid()); | 62 DCHECK(is_valid()); |
| 63 pickle->WriteBytes(&request_digest_, sizeof(request_digest_)); | 63 pickle->WriteBytes(&request_digest_, sizeof(request_digest_)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool HttpVaryData::MatchesRequest( | 66 bool HttpVaryData::MatchesRequest( |
| 67 const HttpRequestInfo& request_info, | 67 const HttpRequestInfo& request_info, |
| 68 const HttpResponseHeaders& cached_response_headers) const { | 68 const HttpResponseHeaders& cached_response_headers) const { |
| 69 HttpVaryData new_vary_data; | 69 HttpVaryData new_vary_data; |
| 70 if (!new_vary_data.Init(request_info, cached_response_headers)) { | 70 if (!new_vary_data.Init(request_info, cached_response_headers)) { |
| 71 // This shouldn't happen provided the same response headers passed here | 71 // This case can happen if |this| was loaded from a cache that was populated |
| 72 // were also used when initializing |this|. | 72 // by a build before crbug.com/469675 was fixed. |
| 73 NOTREACHED(); | |
| 74 return false; | 73 return false; |
| 75 } | 74 } |
| 76 return memcmp(&new_vary_data.request_digest_, &request_digest_, | 75 return memcmp(&new_vary_data.request_digest_, &request_digest_, |
| 77 sizeof(request_digest_)) == 0; | 76 sizeof(request_digest_)) == 0; |
| 78 } | 77 } |
| 79 | 78 |
| 80 // static | 79 // static |
| 81 std::string HttpVaryData::GetRequestValue( | 80 std::string HttpVaryData::GetRequestValue( |
| 82 const HttpRequestInfo& request_info, | 81 const HttpRequestInfo& request_info, |
| 83 const std::string& request_header) { | 82 const std::string& request_header) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 101 // Append a character that cannot appear in the request header line so that we | 100 // Append a character that cannot appear in the request header line so that we |
| 102 // protect against case where the concatenation of two request headers could | 101 // protect against case where the concatenation of two request headers could |
| 103 // look the same for a variety of values for the individual request headers. | 102 // look the same for a variety of values for the individual request headers. |
| 104 // For example, "foo: 12\nbar: 3" looks like "foo: 1\nbar: 23" otherwise. | 103 // For example, "foo: 12\nbar: 3" looks like "foo: 1\nbar: 23" otherwise. |
| 105 request_value.append(1, '\n'); | 104 request_value.append(1, '\n'); |
| 106 | 105 |
| 107 base::MD5Update(ctx, request_value); | 106 base::MD5Update(ctx, request_value); |
| 108 } | 107 } |
| 109 | 108 |
| 110 } // namespace net | 109 } // namespace net |
| OLD | NEW |