| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
| 18 #include "net/cert/ct_policy_enforcer.h" | 18 #include "net/cert/ct_policy_enforcer.h" |
| 19 #include "net/cert/ct_policy_status.h" |
| 19 #include "net/cert/mock_cert_verifier.h" | 20 #include "net/cert/mock_cert_verifier.h" |
| 20 #include "net/cert/multi_log_ct_verifier.h" | 21 #include "net/cert/multi_log_ct_verifier.h" |
| 21 #include "net/http/http_cache.h" | 22 #include "net/http/http_cache.h" |
| 22 #include "net/http/http_network_session.h" | 23 #include "net/http/http_network_session.h" |
| 23 #include "net/http/http_network_transaction.h" | 24 #include "net/http/http_network_transaction.h" |
| 24 #include "net/http/http_server_properties_impl.h" | 25 #include "net/http/http_server_properties_impl.h" |
| 25 #include "net/socket/next_proto.h" | 26 #include "net/socket/next_proto.h" |
| 26 #include "net/socket/socket_test_util.h" | 27 #include "net/socket/socket_test_util.h" |
| 27 #include "net/socket/ssl_client_socket.h" | 28 #include "net/socket/ssl_client_socket.h" |
| 28 #include "net/socket/transport_client_socket_pool.h" | 29 #include "net/socket/transport_client_socket_pool.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 params.time_func = session_deps->time_func; | 397 params.time_func = session_deps->time_func; |
| 397 params.proxy_delegate = session_deps->proxy_delegate.get(); | 398 params.proxy_delegate = session_deps->proxy_delegate.get(); |
| 398 params.enable_http2_alternative_service_with_different_host = | 399 params.enable_http2_alternative_service_with_different_host = |
| 399 session_deps->enable_http2_alternative_service_with_different_host; | 400 session_deps->enable_http2_alternative_service_with_different_host; |
| 400 params.net_log = session_deps->net_log; | 401 params.net_log = session_deps->net_log; |
| 401 params.http_09_on_non_default_ports_enabled = | 402 params.http_09_on_non_default_ports_enabled = |
| 402 session_deps->http_09_on_non_default_ports_enabled; | 403 session_deps->http_09_on_non_default_ports_enabled; |
| 403 return params; | 404 return params; |
| 404 } | 405 } |
| 405 | 406 |
| 407 class AllowAnyCertCTPolicyEnforcer : public CTPolicyEnforcer { |
| 408 public: |
| 409 AllowAnyCertCTPolicyEnforcer(){}; |
| 410 ~AllowAnyCertCTPolicyEnforcer() override = default; |
| 411 |
| 412 ct::CertPolicyCompliance DoesConformToCertPolicy( |
| 413 X509Certificate* cert, |
| 414 const SCTList& verified_scts, |
| 415 const BoundNetLog& net_log) override { |
| 416 return ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS; |
| 417 } |
| 418 |
| 419 ct::EVPolicyCompliance DoesConformToCTEVPolicy( |
| 420 X509Certificate* cert, |
| 421 const ct::EVCertsWhitelist* ev_whitelist, |
| 422 const SCTList& verified_scts, |
| 423 const BoundNetLog& net_log) override { |
| 424 return ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_SCTS; |
| 425 } |
| 426 }; |
| 427 |
| 428 class IgnoresCTVerifier : public net::CTVerifier { |
| 429 public: |
| 430 IgnoresCTVerifier() = default; |
| 431 ~IgnoresCTVerifier() override = default; |
| 432 |
| 433 int Verify(net::X509Certificate* cert, |
| 434 const std::string& stapled_ocsp_response, |
| 435 const std::string& sct_list_from_tls_extension, |
| 436 net::ct::CTVerifyResult* result, |
| 437 const net::BoundNetLog& net_log) override { |
| 438 return net::OK; |
| 439 } |
| 440 |
| 441 void SetObserver(Observer* observer) override {} |
| 442 }; |
| 443 |
| 406 SpdyURLRequestContext::SpdyURLRequestContext() : storage_(this) { | 444 SpdyURLRequestContext::SpdyURLRequestContext() : storage_(this) { |
| 407 storage_.set_host_resolver( | 445 storage_.set_host_resolver( |
| 408 std::unique_ptr<HostResolver>(new MockHostResolver)); | 446 std::unique_ptr<HostResolver>(new MockHostResolver)); |
| 409 storage_.set_cert_verifier(base::WrapUnique(new MockCertVerifier)); | 447 storage_.set_cert_verifier(base::WrapUnique(new MockCertVerifier)); |
| 410 storage_.set_transport_security_state( | 448 storage_.set_transport_security_state( |
| 411 base::WrapUnique(new TransportSecurityState)); | 449 base::WrapUnique(new TransportSecurityState)); |
| 412 storage_.set_proxy_service(ProxyService::CreateDirect()); | 450 storage_.set_proxy_service(ProxyService::CreateDirect()); |
| 451 storage_.set_ct_policy_enforcer( |
| 452 base::WrapUnique(new AllowAnyCertCTPolicyEnforcer())); |
| 453 storage_.set_cert_transparency_verifier( |
| 454 base::WrapUnique(new IgnoresCTVerifier())); |
| 413 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 455 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
| 414 storage_.set_http_auth_handler_factory( | 456 storage_.set_http_auth_handler_factory( |
| 415 HttpAuthHandlerFactory::CreateDefault(host_resolver())); | 457 HttpAuthHandlerFactory::CreateDefault(host_resolver())); |
| 416 storage_.set_http_server_properties( | 458 storage_.set_http_server_properties( |
| 417 std::unique_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 459 std::unique_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
| 418 storage_.set_job_factory(base::WrapUnique(new URLRequestJobFactoryImpl())); | 460 storage_.set_job_factory(base::WrapUnique(new URLRequestJobFactoryImpl())); |
| 419 HttpNetworkSession::Params params; | 461 HttpNetworkSession::Params params; |
| 420 params.client_socket_factory = &socket_factory_; | 462 params.client_socket_factory = &socket_factory_; |
| 421 params.host_resolver = host_resolver(); | 463 params.host_resolver = host_resolver(); |
| 422 params.cert_verifier = cert_verifier(); | 464 params.cert_verifier = cert_verifier(); |
| 423 params.transport_security_state = transport_security_state(); | 465 params.transport_security_state = transport_security_state(); |
| 424 params.proxy_service = proxy_service(); | 466 params.proxy_service = proxy_service(); |
| 467 params.ct_policy_enforcer = ct_policy_enforcer(); |
| 468 params.cert_transparency_verifier = cert_transparency_verifier(); |
| 425 params.ssl_config_service = ssl_config_service(); | 469 params.ssl_config_service = ssl_config_service(); |
| 426 params.http_auth_handler_factory = http_auth_handler_factory(); | 470 params.http_auth_handler_factory = http_auth_handler_factory(); |
| 427 params.enable_spdy_ping_based_connection_checking = false; | 471 params.enable_spdy_ping_based_connection_checking = false; |
| 428 params.http_server_properties = http_server_properties(); | 472 params.http_server_properties = http_server_properties(); |
| 429 storage_.set_http_network_session( | 473 storage_.set_http_network_session( |
| 430 base::WrapUnique(new HttpNetworkSession(params))); | 474 base::WrapUnique(new HttpNetworkSession(params))); |
| 431 SpdySessionPoolPeer pool_peer( | 475 SpdySessionPoolPeer pool_peer( |
| 432 storage_.http_network_session()->spdy_session_pool()); | 476 storage_.http_network_session()->spdy_session_pool()); |
| 433 pool_peer.SetEnableSendingInitialData(false); | 477 pool_peer.SetEnableSendingInitialData(false); |
| 434 storage_.set_http_transaction_factory(base::WrapUnique( | 478 storage_.set_http_transaction_factory(base::WrapUnique( |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 headers[GetSchemeKey()] = scheme.c_str(); | 1143 headers[GetSchemeKey()] = scheme.c_str(); |
| 1100 headers[GetPathKey()] = path.c_str(); | 1144 headers[GetPathKey()] = path.c_str(); |
| 1101 if (content_length) { | 1145 if (content_length) { |
| 1102 std::string length_str = base::Int64ToString(*content_length); | 1146 std::string length_str = base::Int64ToString(*content_length); |
| 1103 headers["content-length"] = length_str; | 1147 headers["content-length"] = length_str; |
| 1104 } | 1148 } |
| 1105 return headers; | 1149 return headers; |
| 1106 } | 1150 } |
| 1107 | 1151 |
| 1108 } // namespace net | 1152 } // namespace net |
| OLD | NEW |