| 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_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 RESPONSE_INFO_WAS_PROXY = 1 << 15, | 74 RESPONSE_INFO_WAS_PROXY = 1 << 15, |
| 75 | 75 |
| 76 // This bit is set if the response info has an SSL connection status field. | 76 // This bit is set if the response info has an SSL connection status field. |
| 77 // This contains the ciphersuite used to fetch the resource as well as the | 77 // This contains the ciphersuite used to fetch the resource as well as the |
| 78 // protocol version, compression method and whether SSLv3 fallback was used. | 78 // protocol version, compression method and whether SSLv3 fallback was used. |
| 79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, | 79 RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16, |
| 80 | 80 |
| 81 // This bit is set if the response info has protocol version. | 81 // This bit is set if the response info has protocol version. |
| 82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, | 82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, |
| 83 | 83 |
| 84 // This bit is set if the request was overriden from cache due to |
| 85 // various load flags being set. |
| 86 RESPONSE_INFO_WAS_CACHE_OVERRIDE = 1 << 18, |
| 87 |
| 84 // TODO(darin): Add other bits to indicate alternate request methods. | 88 // TODO(darin): Add other bits to indicate alternate request methods. |
| 85 // For now, we don't support storing those. | 89 // For now, we don't support storing those. |
| 86 }; | 90 }; |
| 87 | 91 |
| 88 HttpResponseInfo::HttpResponseInfo() | 92 HttpResponseInfo::HttpResponseInfo() |
| 89 : was_cached(false), | 93 : was_cached(false), |
| 94 was_cache_override(false), |
| 90 was_fetched_via_spdy(false), | 95 was_fetched_via_spdy(false), |
| 91 was_npn_negotiated(false), | 96 was_npn_negotiated(false), |
| 92 was_fetched_via_proxy(false) { | 97 was_fetched_via_proxy(false) { |
| 93 } | 98 } |
| 94 | 99 |
| 95 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) | 100 HttpResponseInfo::HttpResponseInfo(const HttpResponseInfo& rhs) |
| 96 : was_cached(rhs.was_cached), | 101 : was_cached(rhs.was_cached), |
| 102 was_cache_override(rhs.was_cache_override), |
| 97 was_fetched_via_spdy(rhs.was_fetched_via_spdy), | 103 was_fetched_via_spdy(rhs.was_fetched_via_spdy), |
| 98 was_npn_negotiated(rhs.was_npn_negotiated), | 104 was_npn_negotiated(rhs.was_npn_negotiated), |
| 99 was_fetched_via_proxy(rhs.was_fetched_via_proxy), | 105 was_fetched_via_proxy(rhs.was_fetched_via_proxy), |
| 100 socket_address(rhs.socket_address), | 106 socket_address(rhs.socket_address), |
| 101 npn_negotiated_protocol(rhs.npn_negotiated_protocol), | 107 npn_negotiated_protocol(rhs.npn_negotiated_protocol), |
| 102 request_time(rhs.request_time), | 108 request_time(rhs.request_time), |
| 103 response_time(rhs.response_time), | 109 response_time(rhs.response_time), |
| 104 auth_challenge(rhs.auth_challenge), | 110 auth_challenge(rhs.auth_challenge), |
| 105 cert_request_info(rhs.cert_request_info), | 111 cert_request_info(rhs.cert_request_info), |
| 106 ssl_info(rhs.ssl_info), | 112 ssl_info(rhs.ssl_info), |
| 107 headers(rhs.headers), | 113 headers(rhs.headers), |
| 108 vary_data(rhs.vary_data), | 114 vary_data(rhs.vary_data), |
| 109 metadata(rhs.metadata) { | 115 metadata(rhs.metadata) { |
| 110 } | 116 } |
| 111 | 117 |
| 112 HttpResponseInfo::~HttpResponseInfo() { | 118 HttpResponseInfo::~HttpResponseInfo() { |
| 113 } | 119 } |
| 114 | 120 |
| 115 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { | 121 HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { |
| 116 was_cached = rhs.was_cached; | 122 was_cached = rhs.was_cached; |
| 123 was_cache_override = rhs.was_cache_override; |
| 117 was_fetched_via_spdy = rhs.was_fetched_via_spdy; | 124 was_fetched_via_spdy = rhs.was_fetched_via_spdy; |
| 118 was_npn_negotiated = rhs.was_npn_negotiated; | 125 was_npn_negotiated = rhs.was_npn_negotiated; |
| 119 was_fetched_via_proxy = rhs.was_fetched_via_proxy; | 126 was_fetched_via_proxy = rhs.was_fetched_via_proxy; |
| 120 socket_address = rhs.socket_address; | 127 socket_address = rhs.socket_address; |
| 121 npn_negotiated_protocol = rhs.npn_negotiated_protocol; | 128 npn_negotiated_protocol = rhs.npn_negotiated_protocol; |
| 122 request_time = rhs.request_time; | 129 request_time = rhs.request_time; |
| 123 response_time = rhs.response_time; | 130 response_time = rhs.response_time; |
| 124 auth_challenge = rhs.auth_challenge; | 131 auth_challenge = rhs.auth_challenge; |
| 125 cert_request_info = rhs.cert_request_info; | 132 cert_request_info = rhs.cert_request_info; |
| 126 ssl_info = rhs.ssl_info; | 133 ssl_info = rhs.ssl_info; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // info, so we don't fail if it can't be read. | 215 // info, so we don't fail if it can't be read. |
| 209 return false; | 216 return false; |
| 210 } | 217 } |
| 211 | 218 |
| 212 // read protocol-version. | 219 // read protocol-version. |
| 213 if (flags & RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL) { | 220 if (flags & RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL) { |
| 214 if (!pickle.ReadString(&iter, &npn_negotiated_protocol)) | 221 if (!pickle.ReadString(&iter, &npn_negotiated_protocol)) |
| 215 return false; | 222 return false; |
| 216 } | 223 } |
| 217 | 224 |
| 225 was_cache_override = (flags & RESPONSE_INFO_WAS_CACHE_OVERRIDE) != 0; |
| 226 |
| 218 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; | 227 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; |
| 219 | 228 |
| 220 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; | 229 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; |
| 221 | 230 |
| 222 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; | 231 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; |
| 223 | 232 |
| 224 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; | 233 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; |
| 225 | 234 |
| 226 return true; | 235 return true; |
| 227 } | 236 } |
| 228 | 237 |
| 229 void HttpResponseInfo::Persist(Pickle* pickle, | 238 void HttpResponseInfo::Persist(Pickle* pickle, |
| 230 bool skip_transient_headers, | 239 bool skip_transient_headers, |
| 231 bool response_truncated) const { | 240 bool response_truncated) const { |
| 232 int flags = RESPONSE_INFO_VERSION; | 241 int flags = RESPONSE_INFO_VERSION; |
| 233 if (ssl_info.is_valid()) { | 242 if (ssl_info.is_valid()) { |
| 234 flags |= RESPONSE_INFO_HAS_CERT; | 243 flags |= RESPONSE_INFO_HAS_CERT; |
| 235 flags |= RESPONSE_INFO_HAS_CERT_STATUS; | 244 flags |= RESPONSE_INFO_HAS_CERT_STATUS; |
| 236 if (ssl_info.security_bits != -1) | 245 if (ssl_info.security_bits != -1) |
| 237 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; | 246 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; |
| 238 if (ssl_info.connection_status != 0) | 247 if (ssl_info.connection_status != 0) |
| 239 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; | 248 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; |
| 240 } | 249 } |
| 241 if (vary_data.is_valid()) | 250 if (vary_data.is_valid()) |
| 242 flags |= RESPONSE_INFO_HAS_VARY_DATA; | 251 flags |= RESPONSE_INFO_HAS_VARY_DATA; |
| 243 if (response_truncated) | 252 if (response_truncated) |
| 244 flags |= RESPONSE_INFO_TRUNCATED; | 253 flags |= RESPONSE_INFO_TRUNCATED; |
| 254 if (was_cache_override) |
| 255 flags |= RESPONSE_INFO_WAS_CACHE_OVERRIDE; |
| 245 if (was_fetched_via_spdy) | 256 if (was_fetched_via_spdy) |
| 246 flags |= RESPONSE_INFO_WAS_SPDY; | 257 flags |= RESPONSE_INFO_WAS_SPDY; |
| 247 if (was_npn_negotiated) { | 258 if (was_npn_negotiated) { |
| 248 flags |= RESPONSE_INFO_WAS_NPN; | 259 flags |= RESPONSE_INFO_WAS_NPN; |
| 249 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; | 260 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; |
| 250 } | 261 } |
| 251 if (was_fetched_via_proxy) | 262 if (was_fetched_via_proxy) |
| 252 flags |= RESPONSE_INFO_WAS_PROXY; | 263 flags |= RESPONSE_INFO_WAS_PROXY; |
| 253 | 264 |
| 254 pickle->WriteInt(flags); | 265 pickle->WriteInt(flags); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 283 vary_data.Persist(pickle); | 294 vary_data.Persist(pickle); |
| 284 | 295 |
| 285 pickle->WriteString(socket_address.host()); | 296 pickle->WriteString(socket_address.host()); |
| 286 pickle->WriteUInt16(socket_address.port()); | 297 pickle->WriteUInt16(socket_address.port()); |
| 287 | 298 |
| 288 if (was_npn_negotiated) | 299 if (was_npn_negotiated) |
| 289 pickle->WriteString(npn_negotiated_protocol); | 300 pickle->WriteString(npn_negotiated_protocol); |
| 290 } | 301 } |
| 291 | 302 |
| 292 } // namespace net | 303 } // namespace net |
| OLD | NEW |