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() == NULL || !pickle.ReadUInt16(&iter, &status)) | |
wtc
2013/11/27 16:32:41
Nit: sct.get() == NULL => !sct.get()
alcutter
2013/11/27 18:05:55
Done.
| |
223 return false; | |
224 ssl_info.signed_certificate_timestamps.push_back( | |
225 SignedCertificateTimestampAndStatus( | |
226 sct, static_cast<SignedCertificateTimestampVerificationStatus>( | |
wtc
2013/11/27 16:32:41
Nit: this is a sign that the enum type's name is t
alcutter
2013/11/27 18:05:55
BahIDoNotKnowWhatYouAreTalkingAboutSeemsJustFineTo
| |
227 status))); | |
228 } | |
229 } | |
230 | |
210 // Read vary-data | 231 // Read vary-data |
211 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { | 232 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { |
212 if (!vary_data.InitFromPickle(pickle, &iter)) | 233 if (!vary_data.InitFromPickle(pickle, &iter)) |
213 return false; | 234 return false; |
214 } | 235 } |
215 | 236 |
216 // Read socket_address. | 237 // Read socket_address. |
217 std::string socket_address_host; | 238 std::string socket_address_host; |
218 if (pickle.ReadString(&iter, &socket_address_host)) { | 239 if (pickle.ReadString(&iter, &socket_address_host)) { |
219 // If the host was written, we always expect the port to follow. | 240 // 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) { | 300 if (was_npn_negotiated) { |
280 flags |= RESPONSE_INFO_WAS_NPN; | 301 flags |= RESPONSE_INFO_WAS_NPN; |
281 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; | 302 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; |
282 } | 303 } |
283 if (was_fetched_via_proxy) | 304 if (was_fetched_via_proxy) |
284 flags |= RESPONSE_INFO_WAS_PROXY; | 305 flags |= RESPONSE_INFO_WAS_PROXY; |
285 if (connection_info != CONNECTION_INFO_UNKNOWN) | 306 if (connection_info != CONNECTION_INFO_UNKNOWN) |
286 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; | 307 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; |
287 if (did_use_http_auth) | 308 if (did_use_http_auth) |
288 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; | 309 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; |
310 if (ssl_info.signed_certificate_timestamps.size() > 0) | |
wtc
2013/11/27 16:32:41
Nit: test !ssl_info.signed_certificate_timestamps.
alcutter
2013/11/27 18:05:55
Done.
| |
311 flags |= RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS; | |
289 | 312 |
290 pickle->WriteInt(flags); | 313 pickle->WriteInt(flags); |
291 pickle->WriteInt64(request_time.ToInternalValue()); | 314 pickle->WriteInt64(request_time.ToInternalValue()); |
292 pickle->WriteInt64(response_time.ToInternalValue()); | 315 pickle->WriteInt64(response_time.ToInternalValue()); |
293 | 316 |
294 net::HttpResponseHeaders::PersistOptions persist_options = | 317 net::HttpResponseHeaders::PersistOptions persist_options = |
295 net::HttpResponseHeaders::PERSIST_RAW; | 318 net::HttpResponseHeaders::PERSIST_RAW; |
296 | 319 |
297 if (skip_transient_headers) { | 320 if (skip_transient_headers) { |
298 persist_options = | 321 persist_options = |
299 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | | 322 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | |
300 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | | 323 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | |
301 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | | 324 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | |
302 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | | 325 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | |
303 net::HttpResponseHeaders::PERSIST_SANS_RANGES | | 326 net::HttpResponseHeaders::PERSIST_SANS_RANGES | |
304 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE; | 327 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE; |
305 } | 328 } |
306 | 329 |
307 headers->Persist(pickle, persist_options); | 330 headers->Persist(pickle, persist_options); |
308 | 331 |
309 if (ssl_info.is_valid()) { | 332 if (ssl_info.is_valid()) { |
310 ssl_info.cert->Persist(pickle); | 333 ssl_info.cert->Persist(pickle); |
311 pickle->WriteUInt32(ssl_info.cert_status); | 334 pickle->WriteUInt32(ssl_info.cert_status); |
312 if (ssl_info.security_bits != -1) | 335 if (ssl_info.security_bits != -1) |
313 pickle->WriteInt(ssl_info.security_bits); | 336 pickle->WriteInt(ssl_info.security_bits); |
314 if (ssl_info.connection_status != 0) | 337 if (ssl_info.connection_status != 0) |
315 pickle->WriteInt(ssl_info.connection_status); | 338 pickle->WriteInt(ssl_info.connection_status); |
339 if (ssl_info.signed_certificate_timestamps.size() > 0) { | |
340 pickle->WriteInt(ssl_info.signed_certificate_timestamps.size()); | |
341 for (SignedCertificateTimestampAndStatusList::const_iterator it = | |
342 ssl_info.signed_certificate_timestamps.begin(); it != | |
343 ssl_info.signed_certificate_timestamps.end(); ++it) { | |
344 it->sct_->Persist(pickle); | |
345 pickle->WriteUInt16(it->status_); | |
346 } | |
347 } | |
316 } | 348 } |
317 | 349 |
318 if (vary_data.is_valid()) | 350 if (vary_data.is_valid()) |
319 vary_data.Persist(pickle); | 351 vary_data.Persist(pickle); |
320 | 352 |
321 pickle->WriteString(socket_address.host()); | 353 pickle->WriteString(socket_address.host()); |
322 pickle->WriteUInt16(socket_address.port()); | 354 pickle->WriteUInt16(socket_address.port()); |
323 | 355 |
324 if (was_npn_negotiated) | 356 if (was_npn_negotiated) |
325 pickle->WriteString(npn_negotiated_protocol); | 357 pickle->WriteString(npn_negotiated_protocol); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 case CONNECTION_INFO_QUIC1_SPDY3: | 403 case CONNECTION_INFO_QUIC1_SPDY3: |
372 return "quic/1+spdy/3"; | 404 return "quic/1+spdy/3"; |
373 case NUM_OF_CONNECTION_INFOS: | 405 case NUM_OF_CONNECTION_INFOS: |
374 break; | 406 break; |
375 } | 407 } |
376 NOTREACHED(); | 408 NOTREACHED(); |
377 return ""; | 409 return ""; |
378 } | 410 } |
379 | 411 |
380 } // namespace net | 412 } // namespace net |
OLD | NEW |