Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_response_info.h" | 5 #include "net/http/http_response_info.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 was_alternate_protocol_available(false), | 67 was_alternate_protocol_available(false), |
| 68 was_fetched_via_proxy(false) { | 68 was_fetched_via_proxy(false) { |
| 69 } | 69 } |
| 70 | 70 |
| 71 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) | 71 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) |
| 72 : was_cached(rhs.was_cached), | 72 : was_cached(rhs.was_cached), |
| 73 was_fetched_via_spdy(rhs.was_fetched_via_spdy), | 73 was_fetched_via_spdy(rhs.was_fetched_via_spdy), |
| 74 was_npn_negotiated(rhs.was_npn_negotiated), | 74 was_npn_negotiated(rhs.was_npn_negotiated), |
| 75 was_alternate_protocol_available(rhs.was_alternate_protocol_available), | 75 was_alternate_protocol_available(rhs.was_alternate_protocol_available), |
| 76 was_fetched_via_proxy(rhs.was_fetched_via_proxy), | 76 was_fetched_via_proxy(rhs.was_fetched_via_proxy), |
| 77 socket_address(rhs.socket_address), | |
| 77 request_time(rhs.request_time), | 78 request_time(rhs.request_time), |
| 78 response_time(rhs.response_time), | 79 response_time(rhs.response_time), |
| 79 auth_challenge(rhs.auth_challenge), | 80 auth_challenge(rhs.auth_challenge), |
| 80 cert_request_info(rhs.cert_request_info), | 81 cert_request_info(rhs.cert_request_info), |
| 81 ssl_info(rhs.ssl_info), | 82 ssl_info(rhs.ssl_info), |
| 82 headers(rhs.headers), | 83 headers(rhs.headers), |
| 83 vary_data(rhs.vary_data), | 84 vary_data(rhs.vary_data), |
| 84 metadata(rhs.metadata) { | 85 metadata(rhs.metadata) { |
| 85 } | 86 } |
| 86 | 87 |
| 87 HttpResponseInfo::~HttpResponseInfo() { | 88 HttpResponseInfo::~HttpResponseInfo() { |
| 88 } | 89 } |
| 89 | 90 |
| 90 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { | 91 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { |
| 91 was_cached = rhs.was_cached; | 92 was_cached = rhs.was_cached; |
| 92 was_fetched_via_spdy = rhs.was_fetched_via_spdy; | 93 was_fetched_via_spdy = rhs.was_fetched_via_spdy; |
| 93 was_npn_negotiated = rhs.was_npn_negotiated; | 94 was_npn_negotiated = rhs.was_npn_negotiated; |
| 94 was_alternate_protocol_available = rhs.was_alternate_protocol_available; | 95 was_alternate_protocol_available = rhs.was_alternate_protocol_available; |
| 95 was_fetched_via_proxy = rhs.was_fetched_via_proxy; | 96 was_fetched_via_proxy = rhs.was_fetched_via_proxy; |
| 97 socket_address = rhs.socket_address; | |
| 96 request_time = rhs.request_time; | 98 request_time = rhs.request_time; |
| 97 response_time = rhs.response_time; | 99 response_time = rhs.response_time; |
| 98 auth_challenge = rhs.auth_challenge; | 100 auth_challenge = rhs.auth_challenge; |
| 99 cert_request_info = rhs.cert_request_info; | 101 cert_request_info = rhs.cert_request_info; |
| 100 ssl_info = rhs.ssl_info; | 102 ssl_info = rhs.ssl_info; |
| 101 headers = rhs.headers; | 103 headers = rhs.headers; |
| 102 vary_data = rhs.vary_data; | 104 vary_data = rhs.vary_data; |
| 103 metadata = rhs.metadata; | 105 metadata = rhs.metadata; |
| 104 return *this; | 106 return *this; |
| 105 } | 107 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 return false; | 153 return false; |
| 152 ssl_info.security_bits = security_bits; | 154 ssl_info.security_bits = security_bits; |
| 153 } | 155 } |
| 154 | 156 |
| 155 // read vary-data | 157 // read vary-data |
| 156 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { | 158 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { |
| 157 if (!vary_data.InitFromPickle(pickle, &iter)) | 159 if (!vary_data.InitFromPickle(pickle, &iter)) |
| 158 return false; | 160 return false; |
| 159 } | 161 } |
| 160 | 162 |
| 163 // Read socket_address. This was not always present in the response info, | |
| 164 // so we don't fail if it can't be read. If additional fields are added in | |
| 165 // a future version, then they must only be read if this operation succeeds. | |
| 166 std::string socket_address_host; | |
| 167 if (pickle.ReadString(&iter, &socket_address_host)) { | |
| 168 // If the host was written, we always expect the port to follow. | |
| 169 uint16 socket_address_port; | |
| 170 if (!pickle.ReadUInt16(&iter, &socket_address_port)) | |
| 171 return false; | |
| 172 socket_address = HostPortPair(socket_address_host, socket_address_port); | |
| 173 } | |
|
wtc
2011/04/21 22:44:25
We should have bumped the version number when we s
Brian Ryner
2011/04/22 00:44:27
Hm, wouldn't that have caused all existing respons
wtc
2011/04/22 19:07:13
We could change the check on line 118 to allow ver
| |
| 174 | |
| 161 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; | 175 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; |
| 162 | 176 |
| 163 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; | 177 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; |
| 164 | 178 |
| 165 was_alternate_protocol_available = | 179 was_alternate_protocol_available = |
| 166 (flags & RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE) != 0; | 180 (flags & RESPONSE_INFO_WAS_ALTERNATE_PROTOCOL_AVAILABLE) != 0; |
| 167 | 181 |
| 168 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; | 182 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; |
| 169 | 183 |
| 170 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) ? true : false; | 184 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) ? true : false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 230 |
| 217 if (ssl_info.is_valid()) { | 231 if (ssl_info.is_valid()) { |
| 218 ssl_info.cert->Persist(pickle); | 232 ssl_info.cert->Persist(pickle); |
| 219 pickle->WriteInt(ssl_info.cert_status); | 233 pickle->WriteInt(ssl_info.cert_status); |
| 220 if (ssl_info.security_bits != -1) | 234 if (ssl_info.security_bits != -1) |
| 221 pickle->WriteInt(ssl_info.security_bits); | 235 pickle->WriteInt(ssl_info.security_bits); |
| 222 } | 236 } |
| 223 | 237 |
| 224 if (vary_data.is_valid()) | 238 if (vary_data.is_valid()) |
| 225 vary_data.Persist(pickle); | 239 vary_data.Persist(pickle); |
| 240 | |
| 241 pickle->WriteString(socket_address.host()); | |
| 242 pickle->WriteUInt16(socket_address.port()); | |
| 226 } | 243 } |
| 227 | 244 |
| 228 } // namespace net | 245 } // namespace net |
| OLD | NEW |