Chromium Code Reviews| 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/time.h" | 9 #include "base/time/time.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, | 86 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, |
| 87 | 87 |
| 88 // This bit is set if the request has http authentication. | 88 // This bit is set if the request has http authentication. |
| 89 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, | 89 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, |
| 90 | 90 |
| 91 // This bit is set if ssl_info has SCTs. | 91 // This bit is set if ssl_info has SCTs. |
| 92 RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS = 1 << 20, | 92 RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS = 1 << 20, |
| 93 | 93 |
| 94 RESPONSE_INFO_UNUSED_SINCE_PREFETCH = 1 << 21, | 94 RESPONSE_INFO_UNUSED_SINCE_PREFETCH = 1 << 21, |
| 95 | 95 |
| 96 // This bit is set if the response has a key-exchange-info field at the end. | |
| 97 RESPONSE_INFO_HAS_KEY_EXCHANGE_INFO = 1 << 22, | |
| 98 | |
| 96 // TODO(darin): Add other bits to indicate alternate request methods. | 99 // TODO(darin): Add other bits to indicate alternate request methods. |
| 97 // For now, we don't support storing those. | 100 // For now, we don't support storing those. |
| 98 }; | 101 }; |
| 99 | 102 |
| 100 HttpResponseInfo::HttpResponseInfo() | 103 HttpResponseInfo::HttpResponseInfo() |
| 101 : was_cached(false), | 104 : was_cached(false), |
| 102 server_data_unavailable(false), | 105 server_data_unavailable(false), |
| 103 network_accessed(false), | 106 network_accessed(false), |
| 104 was_fetched_via_spdy(false), | 107 was_fetched_via_spdy(false), |
| 105 was_npn_negotiated(false), | 108 was_npn_negotiated(false), |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 int value; | 269 int value; |
| 267 if (!iter.ReadInt(&value)) | 270 if (!iter.ReadInt(&value)) |
| 268 return false; | 271 return false; |
| 269 | 272 |
| 270 if (value > static_cast<int>(CONNECTION_INFO_UNKNOWN) && | 273 if (value > static_cast<int>(CONNECTION_INFO_UNKNOWN) && |
| 271 value < static_cast<int>(NUM_OF_CONNECTION_INFOS)) { | 274 value < static_cast<int>(NUM_OF_CONNECTION_INFOS)) { |
| 272 connection_info = static_cast<ConnectionInfo>(value); | 275 connection_info = static_cast<ConnectionInfo>(value); |
| 273 } | 276 } |
| 274 } | 277 } |
| 275 | 278 |
| 279 // Read key_exchange_info | |
| 280 if (flags & RESPONSE_INFO_HAS_KEY_EXCHANGE_INFO) { | |
| 281 int key_exchange_info; | |
| 282 if (!iter.ReadInt(&key_exchange_info)) | |
| 283 return false; | |
| 284 ssl_info.key_exchange_info = key_exchange_info; | |
|
Ryan Sleevi
2015/09/15 08:23:21
Is there any validation of |key_exchange_info| tha
sigbjorn
2015/09/15 08:34:35
This is modelled on security_bits above, which is
estark
2015/09/15 14:37:49
|security_bits| can be -1 and it is actually sanit
sigbjorn
2015/09/15 15:10:56
|key_exchange_info| is already sanity-checked in D
| |
| 285 } | |
| 286 | |
| 276 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; | 287 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; |
| 277 | 288 |
| 278 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; | 289 was_npn_negotiated = (flags & RESPONSE_INFO_WAS_NPN) != 0; |
| 279 | 290 |
| 280 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; | 291 was_fetched_via_proxy = (flags & RESPONSE_INFO_WAS_PROXY) != 0; |
| 281 | 292 |
| 282 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; | 293 *response_truncated = (flags & RESPONSE_INFO_TRUNCATED) != 0; |
| 283 | 294 |
| 284 did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0; | 295 did_use_http_auth = (flags & RESPONSE_INFO_USE_HTTP_AUTHENTICATION) != 0; |
| 285 | 296 |
| 286 unused_since_prefetch = (flags & RESPONSE_INFO_UNUSED_SINCE_PREFETCH) != 0; | 297 unused_since_prefetch = (flags & RESPONSE_INFO_UNUSED_SINCE_PREFETCH) != 0; |
| 287 | 298 |
| 288 return true; | 299 return true; |
| 289 } | 300 } |
| 290 | 301 |
| 291 void HttpResponseInfo::Persist(base::Pickle* pickle, | 302 void HttpResponseInfo::Persist(base::Pickle* pickle, |
| 292 bool skip_transient_headers, | 303 bool skip_transient_headers, |
| 293 bool response_truncated) const { | 304 bool response_truncated) const { |
| 294 int flags = RESPONSE_INFO_VERSION; | 305 int flags = RESPONSE_INFO_VERSION; |
| 295 if (ssl_info.is_valid()) { | 306 if (ssl_info.is_valid()) { |
| 296 flags |= RESPONSE_INFO_HAS_CERT; | 307 flags |= RESPONSE_INFO_HAS_CERT; |
| 297 flags |= RESPONSE_INFO_HAS_CERT_STATUS; | 308 flags |= RESPONSE_INFO_HAS_CERT_STATUS; |
| 298 if (ssl_info.security_bits != -1) | 309 if (ssl_info.security_bits != -1) |
| 299 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; | 310 flags |= RESPONSE_INFO_HAS_SECURITY_BITS; |
| 311 if (ssl_info.key_exchange_info != 0) | |
| 312 flags |= RESPONSE_INFO_HAS_KEY_EXCHANGE_INFO; | |
| 300 if (ssl_info.connection_status != 0) | 313 if (ssl_info.connection_status != 0) |
| 301 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; | 314 flags |= RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS; |
| 302 } | 315 } |
| 303 if (vary_data.is_valid()) | 316 if (vary_data.is_valid()) |
| 304 flags |= RESPONSE_INFO_HAS_VARY_DATA; | 317 flags |= RESPONSE_INFO_HAS_VARY_DATA; |
| 305 if (response_truncated) | 318 if (response_truncated) |
| 306 flags |= RESPONSE_INFO_TRUNCATED; | 319 flags |= RESPONSE_INFO_TRUNCATED; |
| 307 if (was_fetched_via_spdy) | 320 if (was_fetched_via_spdy) |
| 308 flags |= RESPONSE_INFO_WAS_SPDY; | 321 flags |= RESPONSE_INFO_WAS_SPDY; |
| 309 if (was_npn_negotiated) { | 322 if (was_npn_negotiated) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 vary_data.Persist(pickle); | 374 vary_data.Persist(pickle); |
| 362 | 375 |
| 363 pickle->WriteString(socket_address.host()); | 376 pickle->WriteString(socket_address.host()); |
| 364 pickle->WriteUInt16(socket_address.port()); | 377 pickle->WriteUInt16(socket_address.port()); |
| 365 | 378 |
| 366 if (was_npn_negotiated) | 379 if (was_npn_negotiated) |
| 367 pickle->WriteString(npn_negotiated_protocol); | 380 pickle->WriteString(npn_negotiated_protocol); |
| 368 | 381 |
| 369 if (connection_info != CONNECTION_INFO_UNKNOWN) | 382 if (connection_info != CONNECTION_INFO_UNKNOWN) |
| 370 pickle->WriteInt(static_cast<int>(connection_info)); | 383 pickle->WriteInt(static_cast<int>(connection_info)); |
| 384 | |
| 385 // Write key_exchange_info here to provide backwards compatibility | |
|
Ryan Sleevi
2015/09/15 08:23:21
Drop this comment; doesn't feel like it's adding m
sigbjorn
2015/09/15 08:34:35
Done.
| |
| 386 if (ssl_info.is_valid() && ssl_info.key_exchange_info != 0) | |
| 387 pickle->WriteInt(ssl_info.key_exchange_info); | |
| 371 } | 388 } |
| 372 | 389 |
| 373 HttpResponseInfo::ConnectionInfo HttpResponseInfo::ConnectionInfoFromNextProto( | 390 HttpResponseInfo::ConnectionInfo HttpResponseInfo::ConnectionInfoFromNextProto( |
| 374 NextProto next_proto) { | 391 NextProto next_proto) { |
| 375 switch (next_proto) { | 392 switch (next_proto) { |
| 376 case kProtoDeprecatedSPDY2: | 393 case kProtoDeprecatedSPDY2: |
| 377 return CONNECTION_INFO_DEPRECATED_SPDY2; | 394 return CONNECTION_INFO_DEPRECATED_SPDY2; |
| 378 case kProtoSPDY3: | 395 case kProtoSPDY3: |
| 379 case kProtoSPDY31: | 396 case kProtoSPDY31: |
| 380 return CONNECTION_INFO_SPDY3; | 397 return CONNECTION_INFO_SPDY3; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 case CONNECTION_INFO_QUIC1_SPDY3: | 437 case CONNECTION_INFO_QUIC1_SPDY3: |
| 421 return "quic/1+spdy/3"; | 438 return "quic/1+spdy/3"; |
| 422 case NUM_OF_CONNECTION_INFOS: | 439 case NUM_OF_CONNECTION_INFOS: |
| 423 break; | 440 break; |
| 424 } | 441 } |
| 425 NOTREACHED(); | 442 NOTREACHED(); |
| 426 return ""; | 443 return ""; |
| 427 } | 444 } |
| 428 | 445 |
| 429 } // namespace net | 446 } // namespace net |
| OLD | NEW |