| 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 14 matching lines...) Expand all Loading... |
| 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/elements_upload_data_stream.h" | 31 #include "net/base/elements_upload_data_stream.h" |
| 32 #include "net/base/load_timing_info.h" | 32 #include "net/base/load_timing_info.h" |
| 33 #include "net/base/load_timing_info_test_util.h" | 33 #include "net/base/load_timing_info_test_util.h" |
| 34 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 35 #include "net/base/proxy_delegate.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" |
| 41 #include "net/dns/host_cache.h" | 42 #include "net/dns/host_cache.h" |
| 42 #include "net/dns/mock_host_resolver.h" | 43 #include "net/dns/mock_host_resolver.h" |
| 43 #include "net/http/http_auth_challenge_tokenizer.h" | 44 #include "net/http/http_auth_challenge_tokenizer.h" |
| 44 #include "net/http/http_auth_handler_digest.h" | 45 #include "net/http/http_auth_handler_digest.h" |
| (...skipping 11 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.h" | 70 #include "net/socket/client_socket_pool.h" |
| 69 #include "net/socket/client_socket_pool_manager.h" | 71 #include "net/socket/client_socket_pool_manager.h" |
| 70 #include "net/socket/connection_attempts.h" | 72 #include "net/socket/connection_attempts.h" |
| 71 #include "net/socket/mock_client_socket_pool_manager.h" | 73 #include "net/socket/mock_client_socket_pool_manager.h" |
| 72 #include "net/socket/next_proto.h" | 74 #include "net/socket/next_proto.h" |
| 73 #include "net/socket/socket_test_util.h" | 75 #include "net/socket/socket_test_util.h" |
| 74 #include "net/socket/ssl_client_socket.h" | 76 #include "net/socket/ssl_client_socket.h" |
| 75 #include "net/spdy/spdy_framer.h" | 77 #include "net/spdy/spdy_framer.h" |
| (...skipping 7606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7682 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 7684 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
| 7683 TestLoadTimingNotReusedWithPac(load_timing_info, | 7685 TestLoadTimingNotReusedWithPac(load_timing_info, |
| 7684 CONNECT_TIMING_HAS_SSL_TIMES); | 7686 CONNECT_TIMING_HAS_SSL_TIMES); |
| 7685 | 7687 |
| 7686 trans.reset(); | 7688 trans.reset(); |
| 7687 session->CloseAllConnections(); | 7689 session->CloseAllConnections(); |
| 7688 } | 7690 } |
| 7689 | 7691 |
| 7690 // Test that an explicitly trusted SPDY proxy can push a resource from an | 7692 // Test that an explicitly trusted SPDY proxy can push a resource from an |
| 7691 // origin that is different from that of its associated resource. | 7693 // origin that is different from that of its associated resource. |
| 7692 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) { | 7694 TEST_P(HttpNetworkTransactionTest, CrossOriginSPDYProxyPush) { |
| 7695 // Configure the proxy delegate to allow cross-origin SPDY pushes. |
| 7696 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); |
| 7697 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI( |
| 7698 "https://myproxy:443", net::ProxyServer::SCHEME_HTTP)); |
| 7693 HttpRequestInfo request; | 7699 HttpRequestInfo request; |
| 7694 HttpRequestInfo push_request; | 7700 HttpRequestInfo push_request; |
| 7695 | 7701 |
| 7696 request.method = "GET"; | 7702 request.method = "GET"; |
| 7697 request.url = GURL("http://www.example.org/"); | 7703 request.url = GURL("http://www.example.org/"); |
| 7698 push_request.method = "GET"; | 7704 push_request.method = "GET"; |
| 7699 push_request.url = GURL("http://www.another-origin.com/foo.dat"); | 7705 push_request.url = GURL("http://www.another-origin.com/foo.dat"); |
| 7700 | 7706 |
| 7701 // Configure against https proxy server "myproxy:70". | 7707 // Configure against https proxy server "myproxy:443". |
| 7702 session_deps_.proxy_service = | 7708 session_deps_.proxy_service = |
| 7703 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"); | 7709 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:443"); |
| 7704 BoundTestNetLog log; | 7710 BoundTestNetLog log; |
| 7705 session_deps_.net_log = log.bound().net_log(); | 7711 session_deps_.net_log = log.bound().net_log(); |
| 7706 | 7712 |
| 7707 // Enable cross-origin push. | 7713 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
| 7708 session_deps_.trusted_spdy_proxy = "myproxy:70"; | |
| 7709 | 7714 |
| 7710 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7715 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 7711 | 7716 |
| 7712 scoped_ptr<SpdyFrame> stream1_syn( | 7717 scoped_ptr<SpdyFrame> stream1_syn( |
| 7713 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 7718 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 7714 | 7719 |
| 7715 MockWrite spdy_writes[] = { | 7720 MockWrite spdy_writes[] = { |
| 7716 CreateMockWrite(*stream1_syn, 0, ASYNC), | 7721 CreateMockWrite(*stream1_syn, 0, ASYNC), |
| 7717 }; | 7722 }; |
| 7718 | 7723 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7800 EXPECT_EQ(load_timing_info.socket_log_id, | 7805 EXPECT_EQ(load_timing_info.socket_log_id, |
| 7801 push_load_timing_info.socket_log_id); | 7806 push_load_timing_info.socket_log_id); |
| 7802 | 7807 |
| 7803 trans.reset(); | 7808 trans.reset(); |
| 7804 push_trans.reset(); | 7809 push_trans.reset(); |
| 7805 session->CloseAllConnections(); | 7810 session->CloseAllConnections(); |
| 7806 } | 7811 } |
| 7807 | 7812 |
| 7808 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. | 7813 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. |
| 7809 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { | 7814 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { |
| 7815 // Configure the proxy delegate to allow cross-origin SPDY pushes. |
| 7816 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); |
| 7817 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI( |
| 7818 "https://myproxy:443", net::ProxyServer::SCHEME_HTTP)); |
| 7810 HttpRequestInfo request; | 7819 HttpRequestInfo request; |
| 7811 | 7820 |
| 7812 request.method = "GET"; | 7821 request.method = "GET"; |
| 7813 request.url = GURL("http://www.example.org/"); | 7822 request.url = GURL("http://www.example.org/"); |
| 7814 | 7823 |
| 7815 // Configure against https proxy server "myproxy:70". | 7824 session_deps_.proxy_service = |
| 7816 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); | 7825 ProxyService::CreateFixed("https://myproxy:443"); |
| 7817 BoundTestNetLog log; | 7826 BoundTestNetLog log; |
| 7818 session_deps_.net_log = log.bound().net_log(); | 7827 session_deps_.net_log = log.bound().net_log(); |
| 7819 | 7828 |
| 7820 // Enable cross-origin push. | 7829 // Enable cross-origin push. |
| 7821 session_deps_.trusted_spdy_proxy = "myproxy:70"; | 7830 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
| 7822 | 7831 |
| 7823 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 7832 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 7824 | 7833 |
| 7825 scoped_ptr<SpdyFrame> stream1_syn( | 7834 scoped_ptr<SpdyFrame> stream1_syn( |
| 7826 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 7835 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 7827 | 7836 |
| 7828 scoped_ptr<SpdyFrame> push_rst( | 7837 scoped_ptr<SpdyFrame> push_rst( |
| 7829 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 7838 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 7830 | 7839 |
| 7831 MockWrite spdy_writes[] = { | 7840 MockWrite spdy_writes[] = { |
| (...skipping 8051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15883 base::MessageLoop::current()->RunUntilIdle(); | 15892 base::MessageLoop::current()->RunUntilIdle(); |
| 15884 | 15893 |
| 15885 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15894 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15886 HttpRequestHeaders headers; | 15895 HttpRequestHeaders headers; |
| 15887 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15896 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15888 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15897 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15889 } | 15898 } |
| 15890 #endif // !defined(OS_IOS) | 15899 #endif // !defined(OS_IOS) |
| 15891 | 15900 |
| 15892 } // namespace net | 15901 } // namespace net |
| OLD | NEW |