OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
11 #include "net/base/net_log_unittest.h" | 11 #include "net/base/net_log_unittest.h" |
12 #include "net/http/http_network_session_peer.h" | 12 #include "net/http/http_network_session_peer.h" |
13 #include "net/http/http_transaction_unittest.h" | 13 #include "net/http/http_transaction_unittest.h" |
14 #include "net/socket/client_socket_pool_base.h" | 14 #include "net/socket/client_socket_pool_base.h" |
15 #include "net/spdy/spdy_http_stream.h" | 15 #include "net/spdy/spdy_http_stream.h" |
16 #include "net/spdy/spdy_http_utils.h" | 16 #include "net/spdy/spdy_http_utils.h" |
17 #include "net/spdy/spdy_session.h" | 17 #include "net/spdy/spdy_session.h" |
18 #include "net/spdy/spdy_session_pool.h" | 18 #include "net/spdy/spdy_session_pool.h" |
19 #include "net/spdy/spdy_test_util.h" | 19 #include "net/spdy/spdy_test_util.h" |
20 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
21 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
22 | 22 |
23 //----------------------------------------------------------------------------- | 23 //----------------------------------------------------------------------------- |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 // This is the expected list of advertised protocols from the browser's NPN | |
28 // list. | |
29 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; | |
30 | |
31 enum SpdyNetworkTransactionTestTypes { | 27 enum SpdyNetworkTransactionTestTypes { |
32 SPDYNPN, | 28 SPDYNPN, |
33 SPDYNOSSL, | 29 SPDYNOSSL, |
34 SPDYSSL, | 30 SPDYSSL, |
35 }; | 31 }; |
36 class SpdyNetworkTransactionTest | 32 class SpdyNetworkTransactionTest |
37 : public ::testing::TestWithParam<SpdyNetworkTransactionTestTypes> { | 33 : public ::testing::TestWithParam<SpdyNetworkTransactionTestTypes> { |
38 protected: | 34 protected: |
39 | 35 |
40 virtual void SetUp() { | 36 virtual void SetUp() { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 111 |
116 void RunPreTestSetup() { | 112 void RunPreTestSetup() { |
117 if (!session_deps_.get()) | 113 if (!session_deps_.get()) |
118 session_deps_.reset(new SpdySessionDependencies()); | 114 session_deps_.reset(new SpdySessionDependencies()); |
119 if (!session_.get()) | 115 if (!session_.get()) |
120 session_ = SpdySessionDependencies::SpdyCreateSession( | 116 session_ = SpdySessionDependencies::SpdyCreateSession( |
121 session_deps_.get()); | 117 session_deps_.get()); |
122 HttpStreamFactory::set_use_alternate_protocols(false); | 118 HttpStreamFactory::set_use_alternate_protocols(false); |
123 HttpStreamFactory::set_force_spdy_over_ssl(false); | 119 HttpStreamFactory::set_force_spdy_over_ssl(false); |
124 HttpStreamFactory::set_force_spdy_always(false); | 120 HttpStreamFactory::set_force_spdy_always(false); |
| 121 |
| 122 std::vector<std::string> next_protos; |
| 123 next_protos.push_back("http/1.1"); |
| 124 next_protos.push_back("spdy/2"); |
| 125 |
125 switch (test_type_) { | 126 switch (test_type_) { |
126 case SPDYNPN: | 127 case SPDYNPN: |
127 session_->http_server_properties()->SetAlternateProtocol( | 128 session_->http_server_properties()->SetAlternateProtocol( |
128 HostPortPair("www.google.com", 80), 443, | 129 HostPortPair("www.google.com", 80), 443, |
129 NPN_SPDY_2); | 130 NPN_SPDY_2); |
130 HttpStreamFactory::set_use_alternate_protocols(true); | 131 HttpStreamFactory::set_use_alternate_protocols(true); |
131 HttpStreamFactory::set_next_protos(kExpectedNPNString); | 132 HttpStreamFactory::set_next_protos(next_protos); |
132 break; | 133 break; |
133 case SPDYNOSSL: | 134 case SPDYNOSSL: |
134 HttpStreamFactory::set_force_spdy_over_ssl(false); | 135 HttpStreamFactory::set_force_spdy_over_ssl(false); |
135 HttpStreamFactory::set_force_spdy_always(true); | 136 HttpStreamFactory::set_force_spdy_always(true); |
136 break; | 137 break; |
137 case SPDYSSL: | 138 case SPDYSSL: |
138 HttpStreamFactory::set_force_spdy_over_ssl(true); | 139 HttpStreamFactory::set_force_spdy_over_ssl(true); |
139 HttpStreamFactory::set_force_spdy_always(true); | 140 HttpStreamFactory::set_force_spdy_always(true); |
140 break; | 141 break; |
141 default: | 142 default: |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 TestOldCompletionCallback callback1; | 846 TestOldCompletionCallback callback1; |
846 TestOldCompletionCallback callback2; | 847 TestOldCompletionCallback callback2; |
847 | 848 |
848 HttpRequestInfo httpreq = CreateGetRequest(); | 849 HttpRequestInfo httpreq = CreateGetRequest(); |
849 | 850 |
850 // Preconnect the first. | 851 // Preconnect the first. |
851 SSLConfig preconnect_ssl_config; | 852 SSLConfig preconnect_ssl_config; |
852 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); | 853 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); |
853 HttpStreamFactory* http_stream_factory = | 854 HttpStreamFactory* http_stream_factory = |
854 helper.session()->http_stream_factory(); | 855 helper.session()->http_stream_factory(); |
855 if (http_stream_factory->next_protos()) { | 856 if (http_stream_factory->has_next_protos()) { |
856 preconnect_ssl_config.next_protos = *http_stream_factory->next_protos(); | 857 preconnect_ssl_config.next_protos = http_stream_factory->next_protos(); |
857 } | 858 } |
858 | 859 |
859 http_stream_factory->PreconnectStreams( | 860 http_stream_factory->PreconnectStreams( |
860 1, httpreq, preconnect_ssl_config, preconnect_ssl_config, log); | 861 1, httpreq, preconnect_ssl_config, preconnect_ssl_config, log); |
861 | 862 |
862 out.rv = trans1->Start(&httpreq, &callback1, log); | 863 out.rv = trans1->Start(&httpreq, &callback1, log); |
863 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 864 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
864 out.rv = trans2->Start(&httpreq, &callback2, log); | 865 out.rv = trans2->Start(&httpreq, &callback2, log); |
865 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 866 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
866 | 867 |
(...skipping 4788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5655 << " Write index: " | 5656 << " Write index: " |
5656 << data->write_index(); | 5657 << data->write_index(); |
5657 | 5658 |
5658 // Verify the SYN_REPLY. | 5659 // Verify the SYN_REPLY. |
5659 HttpResponseInfo response = *trans->GetResponseInfo(); | 5660 HttpResponseInfo response = *trans->GetResponseInfo(); |
5660 EXPECT_TRUE(response.headers != NULL); | 5661 EXPECT_TRUE(response.headers != NULL); |
5661 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5662 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5662 } | 5663 } |
5663 | 5664 |
5664 } // namespace net | 5665 } // namespace net |
OLD | NEW |