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" |
11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/cert/signed_certificate_timestamp.h" | |
13 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
14 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
15 #include "net/ssl/ssl_cert_request_info.h" | 16 #include "net/ssl/ssl_cert_request_info.h" |
16 | 17 |
17 using base::Time; | 18 using base::Time; |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 | 81 |
81 // This bit is set if the response info has protocol version. | 82 // This bit is set if the response info has protocol version. |
82 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, | 83 RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17, |
83 | 84 |
84 // This bit is set if the response info has connection info. | 85 // This bit is set if the response info has connection info. |
85 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, | 86 RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18, |
86 | 87 |
87 // This bit is set if the request has http authentication. | 88 // This bit is set if the request has http authentication. |
88 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, | 89 RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19, |
89 | 90 |
91 // This bit is set if ssl_info has SCTs. | |
92 RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS = 1 << 20, | |
93 | |
90 // TODO(darin): Add other bits to indicate alternate request methods. | 94 // TODO(darin): Add other bits to indicate alternate request methods. |
91 // For now, we don't support storing those. | 95 // For now, we don't support storing those. |
92 }; | 96 }; |
93 | 97 |
94 HttpResponseInfo::HttpResponseInfo() | 98 HttpResponseInfo::HttpResponseInfo() |
95 : was_cached(false), | 99 : was_cached(false), |
96 server_data_unavailable(false), | 100 server_data_unavailable(false), |
97 network_accessed(false), | 101 network_accessed(false), |
98 was_fetched_via_spdy(false), | 102 was_fetched_via_spdy(false), |
99 was_npn_negotiated(false), | 103 was_npn_negotiated(false), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 ssl_info.security_bits = security_bits; | 204 ssl_info.security_bits = security_bits; |
201 } | 205 } |
202 | 206 |
203 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { | 207 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { |
204 int connection_status; | 208 int connection_status; |
205 if (!pickle.ReadInt(&iter, &connection_status)) | 209 if (!pickle.ReadInt(&iter, &connection_status)) |
206 return false; | 210 return false; |
207 ssl_info.connection_status = connection_status; | 211 ssl_info.connection_status = connection_status; |
208 } | 212 } |
209 | 213 |
214 if (flags & RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS) { | |
215 int num_scts; | |
216 if (!pickle.ReadInt(&iter, &num_scts)) | |
217 return false; | |
218 for (int i = 0; i < num_scts; ++i) { | |
219 scoped_refptr<ct::SignedCertificateTimestamp> sct( | |
220 ct::SignedCertificateTimestamp::CreateFromPickle(&iter)); | |
221 uint16 status; | |
222 if (!sct.get() || !pickle.ReadUInt16(&iter, &status)) | |
223 return false; | |
224 ssl_info.signed_certificate_timestamps.push_back( | |
225 SignedCertificateTimestampAndStatus( | |
226 sct, static_cast<ct::SCTVerifyStatus>(status))); | |
227 } | |
228 } | |
229 | |
210 // Read vary-data | 230 // Read vary-data |
211 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { | 231 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { |
212 if (!vary_data.InitFromPickle(pickle, &iter)) | 232 if (!vary_data.InitFromPickle(pickle, &iter)) |
213 return false; | 233 return false; |
214 } | 234 } |
215 | 235 |
216 // Read socket_address. | 236 // Read socket_address. |
217 std::string socket_address_host; | 237 std::string socket_address_host; |
218 if (pickle.ReadString(&iter, &socket_address_host)) { | 238 if (pickle.ReadString(&iter, &socket_address_host)) { |
219 // If the host was written, we always expect the port to follow. | 239 // If the host was written, we always expect the port to follow. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 if (was_npn_negotiated) { | 299 if (was_npn_negotiated) { |
280 flags |= RESPONSE_INFO_WAS_NPN; | 300 flags |= RESPONSE_INFO_WAS_NPN; |
281 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; | 301 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; |
282 } | 302 } |
283 if (was_fetched_via_proxy) | 303 if (was_fetched_via_proxy) |
284 flags |= RESPONSE_INFO_WAS_PROXY; | 304 flags |= RESPONSE_INFO_WAS_PROXY; |
285 if (connection_info != CONNECTION_INFO_UNKNOWN) | 305 if (connection_info != CONNECTION_INFO_UNKNOWN) |
286 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; | 306 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; |
287 if (did_use_http_auth) | 307 if (did_use_http_auth) |
288 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; | 308 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; |
309 if (!ssl_info.signed_certificate_timestamps.empty()) | |
310 flags |= RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS; | |
289 | 311 |
290 pickle->WriteInt(flags); | 312 pickle->WriteInt(flags); |
291 pickle->WriteInt64(request_time.ToInternalValue()); | 313 pickle->WriteInt64(request_time.ToInternalValue()); |
292 pickle->WriteInt64(response_time.ToInternalValue()); | 314 pickle->WriteInt64(response_time.ToInternalValue()); |
293 | 315 |
294 net::HttpResponseHeaders::PersistOptions persist_options = | 316 net::HttpResponseHeaders::PersistOptions persist_options = |
295 net::HttpResponseHeaders::PERSIST_RAW; | 317 net::HttpResponseHeaders::PERSIST_RAW; |
296 | 318 |
297 if (skip_transient_headers) { | 319 if (skip_transient_headers) { |
298 persist_options = | 320 persist_options = |
299 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | | 321 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | |
300 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | | 322 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | |
301 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | | 323 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | |
302 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | | 324 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | |
303 net::HttpResponseHeaders::PERSIST_SANS_RANGES | | 325 net::HttpResponseHeaders::PERSIST_SANS_RANGES | |
304 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE; | 326 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE; |
305 } | 327 } |
306 | 328 |
307 headers->Persist(pickle, persist_options); | 329 headers->Persist(pickle, persist_options); |
308 | 330 |
309 if (ssl_info.is_valid()) { | 331 if (ssl_info.is_valid()) { |
310 ssl_info.cert->Persist(pickle); | 332 ssl_info.cert->Persist(pickle); |
311 pickle->WriteUInt32(ssl_info.cert_status); | 333 pickle->WriteUInt32(ssl_info.cert_status); |
312 if (ssl_info.security_bits != -1) | 334 if (ssl_info.security_bits != -1) |
313 pickle->WriteInt(ssl_info.security_bits); | 335 pickle->WriteInt(ssl_info.security_bits); |
314 if (ssl_info.connection_status != 0) | 336 if (ssl_info.connection_status != 0) |
315 pickle->WriteInt(ssl_info.connection_status); | 337 pickle->WriteInt(ssl_info.connection_status); |
338 if (ssl_info.signed_certificate_timestamps.size() > 0) { | |
339 pickle->WriteInt(!ssl_info.signed_certificate_timestamps.empty()); | |
wtc
2013/11/28 01:28:02
1. BUG: the argument to pickle->WriteInt() should
alcutter
2013/11/28 12:08:19
Blimey ! O_O
Good catch, thank you.
Done.
wtc
2013/11/28 16:15:07
I learned a new word today. Thanks :-)
| |
340 for (SignedCertificateTimestampAndStatusList::const_iterator it = | |
341 ssl_info.signed_certificate_timestamps.begin(); it != | |
342 ssl_info.signed_certificate_timestamps.end(); ++it) { | |
343 it->sct_->Persist(pickle); | |
344 pickle->WriteUInt16(it->status_); | |
345 } | |
346 } | |
316 } | 347 } |
317 | 348 |
318 if (vary_data.is_valid()) | 349 if (vary_data.is_valid()) |
319 vary_data.Persist(pickle); | 350 vary_data.Persist(pickle); |
320 | 351 |
321 pickle->WriteString(socket_address.host()); | 352 pickle->WriteString(socket_address.host()); |
322 pickle->WriteUInt16(socket_address.port()); | 353 pickle->WriteUInt16(socket_address.port()); |
323 | 354 |
324 if (was_npn_negotiated) | 355 if (was_npn_negotiated) |
325 pickle->WriteString(npn_negotiated_protocol); | 356 pickle->WriteString(npn_negotiated_protocol); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 case CONNECTION_INFO_QUIC1_SPDY3: | 402 case CONNECTION_INFO_QUIC1_SPDY3: |
372 return "quic/1+spdy/3"; | 403 return "quic/1+spdy/3"; |
373 case NUM_OF_CONNECTION_INFOS: | 404 case NUM_OF_CONNECTION_INFOS: |
374 break; | 405 break; |
375 } | 406 } |
376 NOTREACHED(); | 407 NOTREACHED(); |
377 return ""; | 408 return ""; |
378 } | 409 } |
379 | 410 |
380 } // namespace net | 411 } // namespace net |
OLD | NEW |