| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 23 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/test/test_file_util.h" | 26 #include "base/test/test_file_util.h" |
| 27 #include "base/thread_task_runner_handle.h" | 27 #include "base/thread_task_runner_handle.h" |
| 28 #include "net/base/auth.h" | 28 #include "net/base/auth.h" |
| 29 #include "net/base/chunked_upload_data_stream.h" | 29 #include "net/base/chunked_upload_data_stream.h" |
| 30 #include "net/base/completion_callback.h" | 30 #include "net/base/completion_callback.h" |
| 31 #include "net/base/default_trusted_spdy_proxy_provider.h" |
| 31 #include "net/base/elements_upload_data_stream.h" | 32 #include "net/base/elements_upload_data_stream.h" |
| 32 #include "net/base/load_timing_info.h" | 33 #include "net/base/load_timing_info.h" |
| 33 #include "net/base/load_timing_info_test_util.h" | 34 #include "net/base/load_timing_info_test_util.h" |
| 34 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
| 35 #include "net/base/request_priority.h" | 36 #include "net/base/request_priority.h" |
| 36 #include "net/base/test_completion_callback.h" | 37 #include "net/base/test_completion_callback.h" |
| 37 #include "net/base/test_data_directory.h" | 38 #include "net/base/test_data_directory.h" |
| 38 #include "net/base/upload_bytes_element_reader.h" | 39 #include "net/base/upload_bytes_element_reader.h" |
| 39 #include "net/base/upload_file_element_reader.h" | 40 #include "net/base/upload_file_element_reader.h" |
| 40 #include "net/cert/mock_cert_verifier.h" | 41 #include "net/cert/mock_cert_verifier.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 56 #include "net/http/http_stream_parser.h" | 57 #include "net/http/http_stream_parser.h" |
| 57 #include "net/http/http_transaction_test_util.h" | 58 #include "net/http/http_transaction_test_util.h" |
| 58 #include "net/log/net_log.h" | 59 #include "net/log/net_log.h" |
| 59 #include "net/log/test_net_log.h" | 60 #include "net/log/test_net_log.h" |
| 60 #include "net/log/test_net_log_entry.h" | 61 #include "net/log/test_net_log_entry.h" |
| 61 #include "net/log/test_net_log_util.h" | 62 #include "net/log/test_net_log_util.h" |
| 62 #include "net/proxy/mock_proxy_resolver.h" | 63 #include "net/proxy/mock_proxy_resolver.h" |
| 63 #include "net/proxy/proxy_config_service_fixed.h" | 64 #include "net/proxy/proxy_config_service_fixed.h" |
| 64 #include "net/proxy/proxy_info.h" | 65 #include "net/proxy/proxy_info.h" |
| 65 #include "net/proxy/proxy_resolver.h" | 66 #include "net/proxy/proxy_resolver.h" |
| 67 #include "net/proxy/proxy_server.h" |
| 66 #include "net/proxy/proxy_service.h" | 68 #include "net/proxy/proxy_service.h" |
| 67 #include "net/socket/client_socket_factory.h" | 69 #include "net/socket/client_socket_factory.h" |
| 68 #include "net/socket/client_socket_pool_manager.h" | 70 #include "net/socket/client_socket_pool_manager.h" |
| 69 #include "net/socket/connection_attempts.h" | 71 #include "net/socket/connection_attempts.h" |
| 70 #include "net/socket/mock_client_socket_pool_manager.h" | 72 #include "net/socket/mock_client_socket_pool_manager.h" |
| 71 #include "net/socket/next_proto.h" | 73 #include "net/socket/next_proto.h" |
| 72 #include "net/socket/socket_test_util.h" | 74 #include "net/socket/socket_test_util.h" |
| 73 #include "net/socket/ssl_client_socket.h" | 75 #include "net/socket/ssl_client_socket.h" |
| 74 #include "net/spdy/spdy_framer.h" | 76 #include "net/spdy/spdy_framer.h" |
| 75 #include "net/spdy/spdy_session.h" | 77 #include "net/spdy/spdy_session.h" |
| (...skipping 7604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7680 TestLoadTimingNotReusedWithPac(load_timing_info, | 7682 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 7681 CONNECT_TIMING_HAS_SSL_TIMES); | 7683 CONNECT_TIMING_HAS_SSL_TIMES); |
| 7682 | 7684 |
| 7683 trans.reset(); | 7685 trans.reset(); |
| 7684 session->CloseAllConnections(); | 7686 session->CloseAllConnections(); |
| 7685 } | 7687 } |
| 7686 | 7688 |
| 7687 // Test that an explicitly trusted SPDY proxy can push a resource from an | 7689 // Test that an explicitly trusted SPDY proxy can push a resource from an |
| 7688 // origin that is different from that of its associated resource. | 7690 // origin that is different from that of its associated resource. |
| 7689 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) { | 7691 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) { |
| 7692 DefaultTrustedSpdyProxyProvider trusted_spdy_proxy_provider( |
| 7693 net::ProxyServer::FromURI("https://myproxy:443", |
| 7694 net::ProxyServer::SCHEME_HTTP)); |
| 7690 HttpRequestInfo request; | 7695 HttpRequestInfo request; |
| 7691 HttpRequestInfo push_request; | 7696 HttpRequestInfo push_request; |
| 7692 | 7697 |
| 7693 request.method = "GET"; | 7698 request.method = "GET"; |
| 7694 request.url = GURL("http://www.example.org/"); | 7699 request.url = GURL("http://www.example.org/"); |
| 7695 push_request.method = "GET"; | 7700 push_request.method = "GET"; |
| 7696 push_request.url = GURL("http://www.another-origin.com/foo.dat"); | 7701 push_request.url = GURL("http://www.another-origin.com/foo.dat"); |
| 7697 | 7702 |
| 7698 // Configure against https proxy server "myproxy:70". | 7703 // Configure against https proxy server "myproxy:443". |
| 7699 session_deps_.proxy_service = | 7704 session_deps_.proxy_service = |
| 7700 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"); | 7705 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:443"); |
| 7701 BoundTestNetLog log; | 7706 BoundTestNetLog log; |
| 7702 session_deps_.net_log = log.bound().net_log(); | 7707 session_deps_.net_log = log.bound().net_log(); |
| 7703 | 7708 |
| 7704 // Enable cross-origin push. | 7709 // Enable cross-origin push. |
| 7705 session_deps_.trusted_spdy_proxy = "myproxy:70"; | 7710 session_deps_.trusted_spdy_proxy_provider = |
| 7711 trusted_spdy_proxy_provider.GetWeakPtr(); |
| 7706 | 7712 |
| 7707 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7713 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 7708 | 7714 |
| 7709 scoped_ptr<SpdyFrame> stream1_syn( | 7715 scoped_ptr<SpdyFrame> stream1_syn( |
| 7710 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 7716 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 7711 | 7717 |
| 7712 MockWrite spdy_writes[] = { | 7718 MockWrite spdy_writes[] = { |
| 7713 CreateMockWrite(*stream1_syn, 0, ASYNC), | 7719 CreateMockWrite(*stream1_syn, 0, ASYNC), |
| 7714 }; | 7720 }; |
| 7715 | 7721 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7797 EXPECT_EQ(load_timing_info.socket_log_id, | 7803 EXPECT_EQ(load_timing_info.socket_log_id, |
| 7798 push_load_timing_info.socket_log_id); | 7804 push_load_timing_info.socket_log_id); |
| 7799 | 7805 |
| 7800 trans.reset(); | 7806 trans.reset(); |
| 7801 push_trans.reset(); | 7807 push_trans.reset(); |
| 7802 session->CloseAllConnections(); | 7808 session->CloseAllConnections(); |
| 7803 } | 7809 } |
| 7804 | 7810 |
| 7805 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. | 7811 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. |
| 7806 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { | 7812 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { |
| 7813 DefaultTrustedSpdyProxyProvider trusted_spdy_proxy_provider( |
| 7814 net::ProxyServer::FromURI("https://myproxy:443", |
| 7815 net::ProxyServer::SCHEME_HTTP)); |
| 7807 HttpRequestInfo request; | 7816 HttpRequestInfo request; |
| 7808 | 7817 |
| 7809 request.method = "GET"; | 7818 request.method = "GET"; |
| 7810 request.url = GURL("http://www.example.org/"); | 7819 request.url = GURL("http://www.example.org/"); |
| 7811 | 7820 |
| 7812 // Configure against https proxy server "myproxy:70". | 7821 // Configure against https proxy server "myproxy:443". |
| 7813 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); | 7822 session_deps_.proxy_service = |
| 7823 ProxyService::CreateFixed("https://myproxy:443"); |
| 7814 BoundTestNetLog log; | 7824 BoundTestNetLog log; |
| 7815 session_deps_.net_log = log.bound().net_log(); | 7825 session_deps_.net_log = log.bound().net_log(); |
| 7816 | 7826 |
| 7817 // Enable cross-origin push. | 7827 // Enable cross-origin push. |
| 7818 session_deps_.trusted_spdy_proxy = "myproxy:70"; | 7828 session_deps_.trusted_spdy_proxy_provider = |
| 7829 trusted_spdy_proxy_provider.GetWeakPtr(); |
| 7819 | 7830 |
| 7820 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7831 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 7821 | 7832 |
| 7822 scoped_ptr<SpdyFrame> stream1_syn( | 7833 scoped_ptr<SpdyFrame> stream1_syn( |
| 7823 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 7834 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 7824 | 7835 |
| 7825 scoped_ptr<SpdyFrame> push_rst( | 7836 scoped_ptr<SpdyFrame> push_rst( |
| 7826 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 7837 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 7827 | 7838 |
| 7828 MockWrite spdy_writes[] = { | 7839 MockWrite spdy_writes[] = { |
| (...skipping 7967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15796 | 15807 |
| 15797 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 15808 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 15798 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 15809 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 15799 | 15810 |
| 15800 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, | 15811 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, |
| 15801 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); | 15812 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); |
| 15802 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); | 15813 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); |
| 15803 } | 15814 } |
| 15804 | 15815 |
| 15805 } // namespace net | 15816 } // namespace net |
| OLD | NEW |