Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Side by Side Diff: net/http/http_response_info.cc

Issue 88643002: SignedCertificateTimestamp storing & serialization code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erans_patches
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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<net::ct::SignedCertificateTimestamp> sct(
220 ct::SignedCertificateTimestamp::CreateFromPickle(&iter));
221 SignedCertificateTimestampVerificationStatus status;
222 if (sct.get() == NULL || !pickle.ReadUInt16(&iter, &status))
223 return false;
224 ssl_info.signed_certificate_timestamps.push_back(
225 SignedCertificateTimestampAndStatus(sct, status));
226 }
227 }
228
210 // Read vary-data 229 // Read vary-data
211 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { 230 if (flags & RESPONSE_INFO_HAS_VARY_DATA) {
212 if (!vary_data.InitFromPickle(pickle, &iter)) 231 if (!vary_data.InitFromPickle(pickle, &iter))
213 return false; 232 return false;
214 } 233 }
215 234
216 // Read socket_address. 235 // Read socket_address.
217 std::string socket_address_host; 236 std::string socket_address_host;
218 if (pickle.ReadString(&iter, &socket_address_host)) { 237 if (pickle.ReadString(&iter, &socket_address_host)) {
219 // If the host was written, we always expect the port to follow. 238 // If the host was written, we always expect the port to follow.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (was_npn_negotiated) { 298 if (was_npn_negotiated) {
280 flags |= RESPONSE_INFO_WAS_NPN; 299 flags |= RESPONSE_INFO_WAS_NPN;
281 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL; 300 flags |= RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL;
282 } 301 }
283 if (was_fetched_via_proxy) 302 if (was_fetched_via_proxy)
284 flags |= RESPONSE_INFO_WAS_PROXY; 303 flags |= RESPONSE_INFO_WAS_PROXY;
285 if (connection_info != CONNECTION_INFO_UNKNOWN) 304 if (connection_info != CONNECTION_INFO_UNKNOWN)
286 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO; 305 flags |= RESPONSE_INFO_HAS_CONNECTION_INFO;
287 if (did_use_http_auth) 306 if (did_use_http_auth)
288 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION; 307 flags |= RESPONSE_INFO_USE_HTTP_AUTHENTICATION;
308 if (ssl_info.signed_certificate_timestamps.size() > 0)
309 flags |= RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS;
289 310
290 pickle->WriteInt(flags); 311 pickle->WriteInt(flags);
291 pickle->WriteInt64(request_time.ToInternalValue()); 312 pickle->WriteInt64(request_time.ToInternalValue());
292 pickle->WriteInt64(response_time.ToInternalValue()); 313 pickle->WriteInt64(response_time.ToInternalValue());
293 314
294 net::HttpResponseHeaders::PersistOptions persist_options = 315 net::HttpResponseHeaders::PersistOptions persist_options =
295 net::HttpResponseHeaders::PERSIST_RAW; 316 net::HttpResponseHeaders::PERSIST_RAW;
296 317
297 if (skip_transient_headers) { 318 if (skip_transient_headers) {
298 persist_options = 319 persist_options =
299 net::HttpResponseHeaders::PERSIST_SANS_COOKIES | 320 net::HttpResponseHeaders::PERSIST_SANS_COOKIES |
300 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES | 321 net::HttpResponseHeaders::PERSIST_SANS_CHALLENGES |
301 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP | 322 net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP |
302 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE | 323 net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE |
303 net::HttpResponseHeaders::PERSIST_SANS_RANGES | 324 net::HttpResponseHeaders::PERSIST_SANS_RANGES |
304 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE; 325 net::HttpResponseHeaders::PERSIST_SANS_SECURITY_STATE;
305 } 326 }
306 327
307 headers->Persist(pickle, persist_options); 328 headers->Persist(pickle, persist_options);
308 329
309 if (ssl_info.is_valid()) { 330 if (ssl_info.is_valid()) {
310 ssl_info.cert->Persist(pickle); 331 ssl_info.cert->Persist(pickle);
311 pickle->WriteUInt32(ssl_info.cert_status); 332 pickle->WriteUInt32(ssl_info.cert_status);
312 if (ssl_info.security_bits != -1) 333 if (ssl_info.security_bits != -1)
313 pickle->WriteInt(ssl_info.security_bits); 334 pickle->WriteInt(ssl_info.security_bits);
314 if (ssl_info.connection_status != 0) 335 if (ssl_info.connection_status != 0)
315 pickle->WriteInt(ssl_info.connection_status); 336 pickle->WriteInt(ssl_info.connection_status);
337 if (ssl_info.signed_certificate_timestamps.size() > 0) {
338 pickle->WriteInt(ssl_info.signed_certificate_timestamps.size());
339 for (SignedCertificateTimestampAndStatusList::const_iterator it =
340 ssl_info.signed_certificate_timestamps.begin(); it !=
341 ssl_info.signed_certificate_timestamps.end(); ++it) {
342 it->sct_->Persist(pickle);
343 pickle->WriteUInt16(it->status_);
344 }
345 }
316 } 346 }
317 347
318 if (vary_data.is_valid()) 348 if (vary_data.is_valid())
319 vary_data.Persist(pickle); 349 vary_data.Persist(pickle);
320 350
321 pickle->WriteString(socket_address.host()); 351 pickle->WriteString(socket_address.host());
322 pickle->WriteUInt16(socket_address.port()); 352 pickle->WriteUInt16(socket_address.port());
323 353
324 if (was_npn_negotiated) 354 if (was_npn_negotiated)
325 pickle->WriteString(npn_negotiated_protocol); 355 pickle->WriteString(npn_negotiated_protocol);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 case CONNECTION_INFO_QUIC1_SPDY3: 401 case CONNECTION_INFO_QUIC1_SPDY3:
372 return "quic/1+spdy/3"; 402 return "quic/1+spdy/3";
373 case NUM_OF_CONNECTION_INFOS: 403 case NUM_OF_CONNECTION_INFOS:
374 break; 404 break;
375 } 405 }
376 NOTREACHED(); 406 NOTREACHED();
377 return ""; 407 return "";
378 } 408 }
379 409
380 } // namespace net 410 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698