OLD | NEW |
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_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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( | 370 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( |
371 HostResolver* host_resolver, | 371 HostResolver* host_resolver, |
372 CertVerifier* cert_verifier) | 372 CertVerifier* cert_verifier) |
373 : SSLClientSocketPool(0, 0, NULL, host_resolver, cert_verifier, NULL, | 373 : SSLClientSocketPool(0, 0, NULL, host_resolver, cert_verifier, NULL, |
374 NULL, NULL, "", NULL, NULL, NULL, NULL, NULL, NULL) {} | 374 NULL, NULL, "", NULL, NULL, NULL, NULL, NULL, NULL) {} |
375 | 375 |
376 //----------------------------------------------------------------------------- | 376 //----------------------------------------------------------------------------- |
377 | 377 |
378 // This is the expected return from a current server advertising SPDY. | 378 // This is the expected return from a current server advertising SPDY. |
379 static const char kAlternateProtocolHttpHeader[] = | 379 static const char kAlternateProtocolHttpHeader[] = |
380 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; | 380 "Alternate-Protocol: 443:npn-spdy/2.1\r\n\r\n"; |
381 | 381 |
382 // Helper functions for validating that AuthChallengeInfo's are correctly | 382 // Helper functions for validating that AuthChallengeInfo's are correctly |
383 // configured for common cases. | 383 // configured for common cases. |
384 bool CheckBasicServerAuth(const AuthChallengeInfo* auth_challenge) { | 384 bool CheckBasicServerAuth(const AuthChallengeInfo* auth_challenge) { |
385 if (!auth_challenge) | 385 if (!auth_challenge) |
386 return false; | 386 return false; |
387 EXPECT_FALSE(auth_challenge->is_proxy); | 387 EXPECT_FALSE(auth_challenge->is_proxy); |
388 EXPECT_EQ("www.google.com:80", auth_challenge->challenger.ToString()); | 388 EXPECT_EQ("www.google.com:80", auth_challenge->challenger.ToString()); |
389 EXPECT_EQ("MyRealm1", auth_challenge->realm); | 389 EXPECT_EQ("MyRealm1", auth_challenge->realm); |
390 EXPECT_EQ("basic", auth_challenge->scheme); | 390 EXPECT_EQ("basic", auth_challenge->scheme); |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 | 2534 |
2535 scoped_ptr<DelayedSocketData> spdy_data( | 2535 scoped_ptr<DelayedSocketData> spdy_data( |
2536 new DelayedSocketData( | 2536 new DelayedSocketData( |
2537 1, // wait for one write to finish before reading. | 2537 1, // wait for one write to finish before reading. |
2538 spdy_reads, arraysize(spdy_reads), | 2538 spdy_reads, arraysize(spdy_reads), |
2539 spdy_writes, arraysize(spdy_writes))); | 2539 spdy_writes, arraysize(spdy_writes))); |
2540 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2540 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2541 | 2541 |
2542 SSLSocketDataProvider ssl(true, OK); | 2542 SSLSocketDataProvider ssl(true, OK); |
2543 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2543 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2544 ssl.next_proto = "spdy/2"; | 2544 ssl.next_proto = "spdy/2.1"; |
2545 ssl.was_npn_negotiated = true; | 2545 ssl.was_npn_negotiated = true; |
2546 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2546 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2547 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2547 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2548 | 2548 |
2549 TestCompletionCallback callback1; | 2549 TestCompletionCallback callback1; |
2550 | 2550 |
2551 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2551 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
2552 | 2552 |
2553 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2553 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2554 EXPECT_EQ(ERR_IO_PENDING, rv); | 2554 EXPECT_EQ(ERR_IO_PENDING, rv); |
2555 | 2555 |
2556 rv = callback1.WaitForResult(); | 2556 rv = callback1.WaitForResult(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 MockRead(true, 0, 7), | 2621 MockRead(true, 0, 7), |
2622 }; | 2622 }; |
2623 | 2623 |
2624 scoped_ptr<OrderedSocketData> data( | 2624 scoped_ptr<OrderedSocketData> data( |
2625 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), | 2625 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), |
2626 spdy_writes, arraysize(spdy_writes))); | 2626 spdy_writes, arraysize(spdy_writes))); |
2627 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 2627 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
2628 | 2628 |
2629 SSLSocketDataProvider ssl(true, OK); | 2629 SSLSocketDataProvider ssl(true, OK); |
2630 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2630 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2631 ssl.next_proto = "spdy/2"; | 2631 ssl.next_proto = "spdy/2.1"; |
2632 ssl.was_npn_negotiated = true; | 2632 ssl.was_npn_negotiated = true; |
2633 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2633 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2634 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2634 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2635 | 2635 |
2636 TestCompletionCallback callback1; | 2636 TestCompletionCallback callback1; |
2637 | 2637 |
2638 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2638 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
2639 | 2639 |
2640 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2640 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2641 EXPECT_EQ(ERR_IO_PENDING, rv); | 2641 EXPECT_EQ(ERR_IO_PENDING, rv); |
2642 | 2642 |
2643 rv = callback1.WaitForResult(); | 2643 rv = callback1.WaitForResult(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2716 }; | 2716 }; |
2717 | 2717 |
2718 scoped_ptr<OrderedSocketData> spdy_data( | 2718 scoped_ptr<OrderedSocketData> spdy_data( |
2719 new OrderedSocketData( | 2719 new OrderedSocketData( |
2720 spdy_reads, arraysize(spdy_reads), | 2720 spdy_reads, arraysize(spdy_reads), |
2721 spdy_writes, arraysize(spdy_writes))); | 2721 spdy_writes, arraysize(spdy_writes))); |
2722 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2722 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2723 | 2723 |
2724 SSLSocketDataProvider ssl(true, OK); | 2724 SSLSocketDataProvider ssl(true, OK); |
2725 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2725 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2726 ssl.next_proto = "spdy/2"; | 2726 ssl.next_proto = "spdy/2.1"; |
2727 ssl.was_npn_negotiated = true; | 2727 ssl.was_npn_negotiated = true; |
2728 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2728 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2729 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2729 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2730 SSLSocketDataProvider ssl2(true, OK); | 2730 SSLSocketDataProvider ssl2(true, OK); |
2731 ssl2.was_npn_negotiated = false; | 2731 ssl2.was_npn_negotiated = false; |
2732 ssl2.protocol_negotiated = SSLClientSocket::kProtoUnknown; | 2732 ssl2.protocol_negotiated = SSLClientSocket::kProtoUnknown; |
2733 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2733 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2734 | 2734 |
2735 TestCompletionCallback callback1; | 2735 TestCompletionCallback callback1; |
2736 | 2736 |
2737 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2737 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2738 EXPECT_EQ(ERR_IO_PENDING, rv); | 2738 EXPECT_EQ(ERR_IO_PENDING, rv); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2791 }; | 2791 }; |
2792 | 2792 |
2793 scoped_ptr<OrderedSocketData> spdy_data( | 2793 scoped_ptr<OrderedSocketData> spdy_data( |
2794 new OrderedSocketData( | 2794 new OrderedSocketData( |
2795 spdy_reads, arraysize(spdy_reads), | 2795 spdy_reads, arraysize(spdy_reads), |
2796 spdy_writes, arraysize(spdy_writes))); | 2796 spdy_writes, arraysize(spdy_writes))); |
2797 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2797 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2798 | 2798 |
2799 SSLSocketDataProvider ssl(true, OK); | 2799 SSLSocketDataProvider ssl(true, OK); |
2800 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2800 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2801 ssl.next_proto = "spdy/2"; | 2801 ssl.next_proto = "spdy/2.1"; |
2802 ssl.was_npn_negotiated = true; | 2802 ssl.was_npn_negotiated = true; |
2803 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2803 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2804 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2804 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2805 SSLSocketDataProvider ssl2(true, OK); | 2805 SSLSocketDataProvider ssl2(true, OK); |
2806 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2806 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2807 ssl2.next_proto = "spdy/2"; | 2807 ssl2.next_proto = "spdy/2.1"; |
2808 ssl2.was_npn_negotiated = true; | 2808 ssl2.was_npn_negotiated = true; |
2809 ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2809 ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2810 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2810 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2811 | 2811 |
2812 TestCompletionCallback callback1; | 2812 TestCompletionCallback callback1; |
2813 | 2813 |
2814 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2814 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2815 EXPECT_EQ(ERR_IO_PENDING, rv); | 2815 EXPECT_EQ(ERR_IO_PENDING, rv); |
2816 | 2816 |
2817 rv = callback1.WaitForResult(); | 2817 rv = callback1.WaitForResult(); |
2818 EXPECT_EQ(OK, rv); | 2818 EXPECT_EQ(OK, rv); |
2819 | 2819 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 }; | 2860 }; |
2861 | 2861 |
2862 scoped_ptr<OrderedSocketData> spdy_data( | 2862 scoped_ptr<OrderedSocketData> spdy_data( |
2863 new OrderedSocketData( | 2863 new OrderedSocketData( |
2864 spdy_reads, arraysize(spdy_reads), | 2864 spdy_reads, arraysize(spdy_reads), |
2865 spdy_writes, arraysize(spdy_writes))); | 2865 spdy_writes, arraysize(spdy_writes))); |
2866 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2866 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2867 | 2867 |
2868 SSLSocketDataProvider ssl(true, OK); | 2868 SSLSocketDataProvider ssl(true, OK); |
2869 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2869 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2870 ssl.next_proto = "spdy/2"; | 2870 ssl.next_proto = "spdy/2.1"; |
2871 ssl.was_npn_negotiated = true; | 2871 ssl.was_npn_negotiated = true; |
2872 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2872 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2873 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2873 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2874 SSLSocketDataProvider ssl2(true, OK); | 2874 SSLSocketDataProvider ssl2(true, OK); |
2875 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2875 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
2876 ssl2.next_proto = "spdy/2"; | 2876 ssl2.next_proto = "spdy/2.1"; |
2877 ssl2.was_npn_negotiated = true; | 2877 ssl2.was_npn_negotiated = true; |
2878 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 2878 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
2879 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2879 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2880 | 2880 |
2881 TestCompletionCallback callback1; | 2881 TestCompletionCallback callback1; |
2882 | 2882 |
2883 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2883 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2884 EXPECT_EQ(ERR_IO_PENDING, rv); | 2884 EXPECT_EQ(ERR_IO_PENDING, rv); |
2885 | 2885 |
2886 rv = callback1.WaitForResult(); | 2886 rv = callback1.WaitForResult(); |
2887 EXPECT_EQ(OK, rv); | 2887 EXPECT_EQ(OK, rv); |
2888 | 2888 |
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5262 MockRead(true, 0, 2), // EOF | 5262 MockRead(true, 0, 2), // EOF |
5263 }; | 5263 }; |
5264 | 5264 |
5265 scoped_ptr<DelayedSocketData> data( | 5265 scoped_ptr<DelayedSocketData> data( |
5266 new DelayedSocketData( | 5266 new DelayedSocketData( |
5267 1, // wait for one write to finish before reading. | 5267 1, // wait for one write to finish before reading. |
5268 data_reads, arraysize(data_reads), | 5268 data_reads, arraysize(data_reads), |
5269 data_writes, arraysize(data_writes))); | 5269 data_writes, arraysize(data_writes))); |
5270 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 5270 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
5271 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 5271 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
5272 proxy_ssl.next_proto = "spdy/2"; | 5272 proxy_ssl.next_proto = "spdy/2.1"; |
5273 proxy_ssl.was_npn_negotiated = true; | 5273 proxy_ssl.was_npn_negotiated = true; |
5274 proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 5274 proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
5275 | 5275 |
5276 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 5276 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
5277 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 5277 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
5278 | 5278 |
5279 TestCompletionCallback callback; | 5279 TestCompletionCallback callback; |
5280 | 5280 |
5281 scoped_ptr<HttpTransaction> trans( | 5281 scoped_ptr<HttpTransaction> trans( |
5282 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5282 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5283 | 5283 |
5284 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5284 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5382 MockRead(true, 0, 3), // EOF | 5382 MockRead(true, 0, 3), // EOF |
5383 }; | 5383 }; |
5384 | 5384 |
5385 scoped_ptr<DelayedSocketData> data( | 5385 scoped_ptr<DelayedSocketData> data( |
5386 new DelayedSocketData( | 5386 new DelayedSocketData( |
5387 1, // wait for one write to finish before reading. | 5387 1, // wait for one write to finish before reading. |
5388 data_reads, arraysize(data_reads), | 5388 data_reads, arraysize(data_reads), |
5389 data_writes, arraysize(data_writes))); | 5389 data_writes, arraysize(data_writes))); |
5390 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 5390 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
5391 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 5391 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
5392 proxy_ssl.next_proto = "spdy/2"; | 5392 proxy_ssl.next_proto = "spdy/2.1"; |
5393 proxy_ssl.was_npn_negotiated = true; | 5393 proxy_ssl.was_npn_negotiated = true; |
5394 proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 5394 proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
5395 | 5395 |
5396 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 5396 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
5397 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 5397 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
5398 | 5398 |
5399 TestCompletionCallback callback; | 5399 TestCompletionCallback callback; |
5400 | 5400 |
5401 scoped_ptr<HttpTransaction> trans( | 5401 scoped_ptr<HttpTransaction> trans( |
5402 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5402 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5403 | 5403 |
5404 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5404 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6138 }; | 6138 }; |
6139 | 6139 |
6140 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( | 6140 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( |
6141 SessionDependencies* session_deps) { | 6141 SessionDependencies* session_deps) { |
6142 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); | 6142 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); |
6143 | 6143 |
6144 HttpServerProperties* http_server_properties = | 6144 HttpServerProperties* http_server_properties = |
6145 session->http_server_properties(); | 6145 session->http_server_properties(); |
6146 http_server_properties->SetAlternateProtocol( | 6146 http_server_properties->SetAlternateProtocol( |
6147 HostPortPair("host.with.alternate", 80), 443, | 6147 HostPortPair("host.with.alternate", 80), 443, |
6148 NPN_SPDY_2); | 6148 NPN_SPDY_21); |
6149 | 6149 |
6150 return session; | 6150 return session; |
6151 } | 6151 } |
6152 | 6152 |
6153 int GroupNameTransactionHelper( | 6153 int GroupNameTransactionHelper( |
6154 const std::string& url, | 6154 const std::string& url, |
6155 const scoped_refptr<HttpNetworkSession>& session) { | 6155 const scoped_refptr<HttpNetworkSession>& session) { |
6156 HttpRequestInfo request; | 6156 HttpRequestInfo request; |
6157 request.method = "GET"; | 6157 request.method = "GET"; |
6158 request.url = GURL(url); | 6158 request.url = GURL(url); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7078 | 7078 |
7079 std::string response_data; | 7079 std::string response_data; |
7080 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7080 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7081 EXPECT_EQ("hello world", response_data); | 7081 EXPECT_EQ("hello world", response_data); |
7082 | 7082 |
7083 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 7083 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
7084 const PortAlternateProtocolPair alternate = | 7084 const PortAlternateProtocolPair alternate = |
7085 http_server_properties.GetAlternateProtocol(http_host_port_pair); | 7085 http_server_properties.GetAlternateProtocol(http_host_port_pair); |
7086 PortAlternateProtocolPair expected_alternate; | 7086 PortAlternateProtocolPair expected_alternate; |
7087 expected_alternate.port = 443; | 7087 expected_alternate.port = 443; |
7088 expected_alternate.protocol = NPN_SPDY_2; | 7088 expected_alternate.protocol = NPN_SPDY_21; |
7089 EXPECT_TRUE(expected_alternate.Equals(alternate)); | 7089 EXPECT_TRUE(expected_alternate.Equals(alternate)); |
7090 | 7090 |
7091 HttpStreamFactory::set_use_alternate_protocols(false); | 7091 HttpStreamFactory::set_use_alternate_protocols(false); |
7092 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 7092 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
7093 } | 7093 } |
7094 | 7094 |
7095 TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) { | 7095 TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) { |
7096 HttpStreamFactory::set_use_alternate_protocols(true); | 7096 HttpStreamFactory::set_use_alternate_protocols(true); |
7097 SessionDependencies session_deps; | 7097 SessionDependencies session_deps; |
7098 | 7098 |
(...skipping 18 matching lines...) Expand all Loading... |
7117 | 7117 |
7118 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7118 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
7119 | 7119 |
7120 HttpServerProperties* http_server_properties = | 7120 HttpServerProperties* http_server_properties = |
7121 session->http_server_properties(); | 7121 session->http_server_properties(); |
7122 // Port must be < 1024, or the header will be ignored (since initial port was | 7122 // Port must be < 1024, or the header will be ignored (since initial port was |
7123 // port 80 (another restricted port). | 7123 // port 80 (another restricted port). |
7124 http_server_properties->SetAlternateProtocol( | 7124 http_server_properties->SetAlternateProtocol( |
7125 HostPortPair::FromURL(request.url), | 7125 HostPortPair::FromURL(request.url), |
7126 666 /* port is ignored by MockConnect anyway */, | 7126 666 /* port is ignored by MockConnect anyway */, |
7127 NPN_SPDY_2); | 7127 NPN_SPDY_21); |
7128 | 7128 |
7129 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7129 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7130 TestCompletionCallback callback; | 7130 TestCompletionCallback callback; |
7131 | 7131 |
7132 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7132 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
7133 EXPECT_EQ(ERR_IO_PENDING, rv); | 7133 EXPECT_EQ(ERR_IO_PENDING, rv); |
7134 EXPECT_EQ(OK, callback.WaitForResult()); | 7134 EXPECT_EQ(OK, callback.WaitForResult()); |
7135 | 7135 |
7136 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7136 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7137 ASSERT_TRUE(response != NULL); | 7137 ASSERT_TRUE(response != NULL); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7179 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7179 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
7180 | 7180 |
7181 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7181 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
7182 | 7182 |
7183 HttpServerProperties* http_server_properties = | 7183 HttpServerProperties* http_server_properties = |
7184 session->http_server_properties(); | 7184 session->http_server_properties(); |
7185 const int kUnrestrictedAlternatePort = 1024; | 7185 const int kUnrestrictedAlternatePort = 1024; |
7186 http_server_properties->SetAlternateProtocol( | 7186 http_server_properties->SetAlternateProtocol( |
7187 HostPortPair::FromURL(restricted_port_request.url), | 7187 HostPortPair::FromURL(restricted_port_request.url), |
7188 kUnrestrictedAlternatePort, | 7188 kUnrestrictedAlternatePort, |
7189 NPN_SPDY_2); | 7189 NPN_SPDY_21); |
7190 | 7190 |
7191 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7191 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7192 TestCompletionCallback callback; | 7192 TestCompletionCallback callback; |
7193 | 7193 |
7194 int rv = trans->Start( | 7194 int rv = trans->Start( |
7195 &restricted_port_request, callback.callback(), BoundNetLog()); | 7195 &restricted_port_request, callback.callback(), BoundNetLog()); |
7196 EXPECT_EQ(ERR_IO_PENDING, rv); | 7196 EXPECT_EQ(ERR_IO_PENDING, rv); |
7197 // Invalid change to unrestricted port should fail. | 7197 // Invalid change to unrestricted port should fail. |
7198 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 7198 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
7199 | 7199 |
(...skipping 28 matching lines...) Expand all Loading... |
7228 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7228 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
7229 | 7229 |
7230 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7230 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
7231 | 7231 |
7232 HttpServerProperties* http_server_properties = | 7232 HttpServerProperties* http_server_properties = |
7233 session->http_server_properties(); | 7233 session->http_server_properties(); |
7234 const int kRestrictedAlternatePort = 80; | 7234 const int kRestrictedAlternatePort = 80; |
7235 http_server_properties->SetAlternateProtocol( | 7235 http_server_properties->SetAlternateProtocol( |
7236 HostPortPair::FromURL(restricted_port_request.url), | 7236 HostPortPair::FromURL(restricted_port_request.url), |
7237 kRestrictedAlternatePort, | 7237 kRestrictedAlternatePort, |
7238 NPN_SPDY_2); | 7238 NPN_SPDY_21); |
7239 | 7239 |
7240 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7240 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7241 TestCompletionCallback callback; | 7241 TestCompletionCallback callback; |
7242 | 7242 |
7243 int rv = trans->Start( | 7243 int rv = trans->Start( |
7244 &restricted_port_request, callback.callback(), BoundNetLog()); | 7244 &restricted_port_request, callback.callback(), BoundNetLog()); |
7245 EXPECT_EQ(ERR_IO_PENDING, rv); | 7245 EXPECT_EQ(ERR_IO_PENDING, rv); |
7246 // Valid change to restricted port should pass. | 7246 // Valid change to restricted port should pass. |
7247 EXPECT_EQ(OK, callback.WaitForResult()); | 7247 EXPECT_EQ(OK, callback.WaitForResult()); |
7248 | 7248 |
(...skipping 28 matching lines...) Expand all Loading... |
7277 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7277 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
7278 | 7278 |
7279 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7279 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
7280 | 7280 |
7281 HttpServerProperties* http_server_properties = | 7281 HttpServerProperties* http_server_properties = |
7282 session->http_server_properties(); | 7282 session->http_server_properties(); |
7283 const int kRestrictedAlternatePort = 80; | 7283 const int kRestrictedAlternatePort = 80; |
7284 http_server_properties->SetAlternateProtocol( | 7284 http_server_properties->SetAlternateProtocol( |
7285 HostPortPair::FromURL(unrestricted_port_request.url), | 7285 HostPortPair::FromURL(unrestricted_port_request.url), |
7286 kRestrictedAlternatePort, | 7286 kRestrictedAlternatePort, |
7287 NPN_SPDY_2); | 7287 NPN_SPDY_21); |
7288 | 7288 |
7289 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7289 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7290 TestCompletionCallback callback; | 7290 TestCompletionCallback callback; |
7291 | 7291 |
7292 int rv = trans->Start( | 7292 int rv = trans->Start( |
7293 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 7293 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
7294 EXPECT_EQ(ERR_IO_PENDING, rv); | 7294 EXPECT_EQ(ERR_IO_PENDING, rv); |
7295 // Valid change to restricted port should pass. | 7295 // Valid change to restricted port should pass. |
7296 EXPECT_EQ(OK, callback.WaitForResult()); | 7296 EXPECT_EQ(OK, callback.WaitForResult()); |
7297 | 7297 |
(...skipping 28 matching lines...) Expand all Loading... |
7326 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7326 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
7327 | 7327 |
7328 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7328 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
7329 | 7329 |
7330 HttpServerProperties* http_server_properties = | 7330 HttpServerProperties* http_server_properties = |
7331 session->http_server_properties(); | 7331 session->http_server_properties(); |
7332 const int kUnrestrictedAlternatePort = 1024; | 7332 const int kUnrestrictedAlternatePort = 1024; |
7333 http_server_properties->SetAlternateProtocol( | 7333 http_server_properties->SetAlternateProtocol( |
7334 HostPortPair::FromURL(unrestricted_port_request.url), | 7334 HostPortPair::FromURL(unrestricted_port_request.url), |
7335 kUnrestrictedAlternatePort, | 7335 kUnrestrictedAlternatePort, |
7336 NPN_SPDY_2); | 7336 NPN_SPDY_21); |
7337 | 7337 |
7338 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7338 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7339 TestCompletionCallback callback; | 7339 TestCompletionCallback callback; |
7340 | 7340 |
7341 int rv = trans->Start( | 7341 int rv = trans->Start( |
7342 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 7342 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
7343 EXPECT_EQ(ERR_IO_PENDING, rv); | 7343 EXPECT_EQ(ERR_IO_PENDING, rv); |
7344 // Valid change to an unrestricted port should pass. | 7344 // Valid change to an unrestricted port should pass. |
7345 EXPECT_EQ(OK, callback.WaitForResult()); | 7345 EXPECT_EQ(OK, callback.WaitForResult()); |
7346 | 7346 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7417 MockRead("hello world"), | 7417 MockRead("hello world"), |
7418 MockRead(true, OK), | 7418 MockRead(true, OK), |
7419 }; | 7419 }; |
7420 | 7420 |
7421 StaticSocketDataProvider first_transaction( | 7421 StaticSocketDataProvider first_transaction( |
7422 data_reads, arraysize(data_reads), NULL, 0); | 7422 data_reads, arraysize(data_reads), NULL, 0); |
7423 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7423 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7424 | 7424 |
7425 SSLSocketDataProvider ssl(true, OK); | 7425 SSLSocketDataProvider ssl(true, OK); |
7426 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 7426 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
7427 ssl.next_proto = "spdy/2"; | 7427 ssl.next_proto = "spdy/2.1"; |
7428 ssl.was_npn_negotiated = true; | 7428 ssl.was_npn_negotiated = true; |
7429 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 7429 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
7430 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7430 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7431 | 7431 |
7432 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7432 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7433 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 7433 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
7434 | 7434 |
7435 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7435 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
7436 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7436 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
7437 MockRead spdy_reads[] = { | 7437 MockRead spdy_reads[] = { |
7438 CreateMockRead(*resp), | 7438 CreateMockRead(*resp), |
7439 CreateMockRead(*data), | 7439 CreateMockRead(*data), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7519 StaticSocketDataProvider hanging_socket( | 7519 StaticSocketDataProvider hanging_socket( |
7520 NULL, 0, NULL, 0); | 7520 NULL, 0, NULL, 0); |
7521 hanging_socket.set_connect_data(never_finishing_connect); | 7521 hanging_socket.set_connect_data(never_finishing_connect); |
7522 // Socket 2 and 3 are the hanging Alternate-Protocol and | 7522 // Socket 2 and 3 are the hanging Alternate-Protocol and |
7523 // non-Alternate-Protocol jobs from the 2nd transaction. | 7523 // non-Alternate-Protocol jobs from the 2nd transaction. |
7524 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7524 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); |
7525 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7525 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); |
7526 | 7526 |
7527 SSLSocketDataProvider ssl(true, OK); | 7527 SSLSocketDataProvider ssl(true, OK); |
7528 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 7528 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
7529 ssl.next_proto = "spdy/2"; | 7529 ssl.next_proto = "spdy/2.1"; |
7530 ssl.was_npn_negotiated = true; | 7530 ssl.was_npn_negotiated = true; |
7531 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 7531 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
7532 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7532 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7533 | 7533 |
7534 scoped_ptr<spdy::SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7534 scoped_ptr<spdy::SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7535 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 7535 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
7536 MockWrite spdy_writes[] = { | 7536 MockWrite spdy_writes[] = { |
7537 CreateMockWrite(*req1), | 7537 CreateMockWrite(*req1), |
7538 CreateMockWrite(*req2), | 7538 CreateMockWrite(*req2), |
7539 }; | 7539 }; |
7540 scoped_ptr<spdy::SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7540 scoped_ptr<spdy::SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); |
7541 scoped_ptr<spdy::SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); | 7541 scoped_ptr<spdy::SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7628 MockRead("hello world"), | 7628 MockRead("hello world"), |
7629 MockRead(true, OK), | 7629 MockRead(true, OK), |
7630 }; | 7630 }; |
7631 | 7631 |
7632 StaticSocketDataProvider first_transaction( | 7632 StaticSocketDataProvider first_transaction( |
7633 data_reads, arraysize(data_reads), NULL, 0); | 7633 data_reads, arraysize(data_reads), NULL, 0); |
7634 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7634 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7635 | 7635 |
7636 SSLSocketDataProvider ssl(true, OK); | 7636 SSLSocketDataProvider ssl(true, OK); |
7637 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 7637 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
7638 ssl.next_proto = "spdy/2"; | 7638 ssl.next_proto = "spdy/2.1"; |
7639 ssl.was_npn_negotiated = true; | 7639 ssl.was_npn_negotiated = true; |
7640 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 7640 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
7641 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7641 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7642 | 7642 |
7643 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 7643 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
7644 StaticSocketDataProvider hanging_alternate_protocol_socket( | 7644 StaticSocketDataProvider hanging_alternate_protocol_socket( |
7645 NULL, 0, NULL, 0); | 7645 NULL, 0, NULL, 0); |
7646 hanging_alternate_protocol_socket.set_connect_data( | 7646 hanging_alternate_protocol_socket.set_connect_data( |
7647 never_finishing_connect); | 7647 never_finishing_connect); |
7648 session_deps.socket_factory.AddSocketDataProvider( | 7648 session_deps.socket_factory.AddSocketDataProvider( |
7649 &hanging_alternate_protocol_socket); | 7649 &hanging_alternate_protocol_socket); |
7650 | 7650 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7763 MockRead("hello world"), | 7763 MockRead("hello world"), |
7764 MockRead(true, OK), | 7764 MockRead(true, OK), |
7765 }; | 7765 }; |
7766 | 7766 |
7767 StaticSocketDataProvider first_transaction( | 7767 StaticSocketDataProvider first_transaction( |
7768 data_reads, arraysize(data_reads), NULL, 0); | 7768 data_reads, arraysize(data_reads), NULL, 0); |
7769 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7769 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7770 | 7770 |
7771 SSLSocketDataProvider ssl(true, OK); | 7771 SSLSocketDataProvider ssl(true, OK); |
7772 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 7772 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
7773 ssl.next_proto = "spdy/2"; | 7773 ssl.next_proto = "spdy/2.1"; |
7774 ssl.was_npn_negotiated = true; | 7774 ssl.was_npn_negotiated = true; |
7775 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 7775 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
7776 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7776 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7777 | 7777 |
7778 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7778 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7779 MockWrite spdy_writes[] = { | 7779 MockWrite spdy_writes[] = { |
7780 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 7780 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
7781 "Host: www.google.com\r\n" | 7781 "Host: www.google.com\r\n" |
7782 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 | 7782 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 |
7783 CreateMockWrite(*req) // 3 | 7783 CreateMockWrite(*req) // 3 |
7784 }; | 7784 }; |
7785 | 7785 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7870 MockRead("hello world"), | 7870 MockRead("hello world"), |
7871 MockRead(true, OK), | 7871 MockRead(true, OK), |
7872 }; | 7872 }; |
7873 | 7873 |
7874 StaticSocketDataProvider first_transaction( | 7874 StaticSocketDataProvider first_transaction( |
7875 data_reads, arraysize(data_reads), NULL, 0); | 7875 data_reads, arraysize(data_reads), NULL, 0); |
7876 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7876 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7877 | 7877 |
7878 SSLSocketDataProvider ssl(true, OK); | 7878 SSLSocketDataProvider ssl(true, OK); |
7879 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 7879 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
7880 ssl.next_proto = "spdy/2"; | 7880 ssl.next_proto = "spdy/2.1"; |
7881 ssl.was_npn_negotiated = true; | 7881 ssl.was_npn_negotiated = true; |
7882 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 7882 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
7883 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7883 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7884 // Make sure we use ssl for spdy here. | 7884 // Make sure we use ssl for spdy here. |
7885 SpdySession::SetSSLMode(true); | 7885 SpdySession::SetSSLMode(true); |
7886 | 7886 |
7887 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7887 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7888 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 7888 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
7889 | 7889 |
7890 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7890 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
7891 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7891 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
7892 MockRead spdy_reads[] = { | 7892 MockRead spdy_reads[] = { |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8757 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 8757 HttpStreamFactory::set_next_protos(SpdyNextProtos()); |
8758 SessionDependencies session_deps; | 8758 SessionDependencies session_deps; |
8759 | 8759 |
8760 HttpRequestInfo request; | 8760 HttpRequestInfo request; |
8761 request.method = "GET"; | 8761 request.method = "GET"; |
8762 request.url = GURL("https://www.google.com/"); | 8762 request.url = GURL("https://www.google.com/"); |
8763 request.load_flags = 0; | 8763 request.load_flags = 0; |
8764 | 8764 |
8765 SSLSocketDataProvider ssl(true, OK); | 8765 SSLSocketDataProvider ssl(true, OK); |
8766 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 8766 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
8767 ssl.next_proto = "spdy/2"; | 8767 ssl.next_proto = "spdy/2.1"; |
8768 ssl.was_npn_negotiated = true; | 8768 ssl.was_npn_negotiated = true; |
8769 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 8769 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
8770 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8770 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
8771 | 8771 |
8772 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 8772 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
8773 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 8773 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
8774 | 8774 |
8775 MockRead spdy_reads[] = { | 8775 MockRead spdy_reads[] = { |
8776 MockRead(false, 0, 0) // Not async - return 0 immediately. | 8776 MockRead(false, 0, 0) // Not async - return 0 immediately. |
8777 }; | 8777 }; |
8778 | 8778 |
8779 scoped_ptr<DelayedSocketData> spdy_data( | 8779 scoped_ptr<DelayedSocketData> spdy_data( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8820 // First round goes unauthenticated through the proxy. | 8820 // First round goes unauthenticated through the proxy. |
8821 MockWrite data_writes_1[] = { | 8821 MockWrite data_writes_1[] = { |
8822 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 8822 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
8823 "Host: www.google.com\r\n" | 8823 "Host: www.google.com\r\n" |
8824 "Proxy-Connection: keep-alive\r\n" | 8824 "Proxy-Connection: keep-alive\r\n" |
8825 "\r\n"), | 8825 "\r\n"), |
8826 }; | 8826 }; |
8827 MockRead data_reads_1[] = { | 8827 MockRead data_reads_1[] = { |
8828 MockRead(false, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 8828 MockRead(false, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
8829 MockRead("HTTP/1.1 200 OK\r\n" | 8829 MockRead("HTTP/1.1 200 OK\r\n" |
8830 "Alternate-Protocol: 443:npn-spdy/2\r\n" | 8830 "Alternate-Protocol: 443:npn-spdy/2.1\r\n" |
8831 "Proxy-Connection: close\r\n" | 8831 "Proxy-Connection: close\r\n" |
8832 "\r\n"), | 8832 "\r\n"), |
8833 }; | 8833 }; |
8834 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | 8834 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), |
8835 data_writes_1, arraysize(data_writes_1)); | 8835 data_writes_1, arraysize(data_writes_1)); |
8836 | 8836 |
8837 // Second round tries to tunnel to www.google.com due to the | 8837 // Second round tries to tunnel to www.google.com due to the |
8838 // Alternate-Protocol announcement in the first round. It fails due | 8838 // Alternate-Protocol announcement in the first round. It fails due |
8839 // to a proxy authentication challenge. | 8839 // to a proxy authentication challenge. |
8840 // After the failure, a tunnel is established to www.google.com using | 8840 // After the failure, a tunnel is established to www.google.com using |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8913 data_writes_3, arraysize(data_writes_3))); | 8913 data_writes_3, arraysize(data_writes_3))); |
8914 // Hang forever so we can ensure the alt job wins | 8914 // Hang forever so we can ensure the alt job wins |
8915 MockConnect conn_3(false, ERR_IO_PENDING); | 8915 MockConnect conn_3(false, ERR_IO_PENDING); |
8916 data_3->set_connect_data(conn_3); | 8916 data_3->set_connect_data(conn_3); |
8917 scoped_ptr<OrderedSocketData> data_4( | 8917 scoped_ptr<OrderedSocketData> data_4( |
8918 new OrderedSocketData(data_reads_4, arraysize(data_reads_4), | 8918 new OrderedSocketData(data_reads_4, arraysize(data_reads_4), |
8919 data_writes_4, arraysize(data_writes_4))); | 8919 data_writes_4, arraysize(data_writes_4))); |
8920 | 8920 |
8921 SSLSocketDataProvider ssl(true, OK); | 8921 SSLSocketDataProvider ssl(true, OK); |
8922 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 8922 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
8923 ssl.next_proto = "spdy/2"; | 8923 ssl.next_proto = "spdy/2.1"; |
8924 ssl.was_npn_negotiated = true; | 8924 ssl.was_npn_negotiated = true; |
8925 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 8925 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
8926 | 8926 |
8927 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 8927 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
8928 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 8928 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
8929 NULL, 0, NULL, 0); | 8929 NULL, 0, NULL, 0); |
8930 hanging_non_alternate_protocol_socket.set_connect_data( | 8930 hanging_non_alternate_protocol_socket.set_connect_data( |
8931 never_finishing_connect); | 8931 never_finishing_connect); |
8932 | 8932 |
8933 session_deps.socket_factory.AddSocketDataProvider(&data_1); | 8933 session_deps.socket_factory.AddSocketDataProvider(&data_1); |
8934 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); | 8934 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); |
8935 session_deps.socket_factory.AddSocketDataProvider(data_3.get()); | 8935 session_deps.socket_factory.AddSocketDataProvider(data_3.get()); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9200 | 9200 |
9201 scoped_ptr<DelayedSocketData> spdy_data( | 9201 scoped_ptr<DelayedSocketData> spdy_data( |
9202 new DelayedSocketData( | 9202 new DelayedSocketData( |
9203 1, // wait for one write to finish before reading. | 9203 1, // wait for one write to finish before reading. |
9204 spdy_reads, arraysize(spdy_reads), | 9204 spdy_reads, arraysize(spdy_reads), |
9205 spdy_writes, arraysize(spdy_writes))); | 9205 spdy_writes, arraysize(spdy_writes))); |
9206 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 9206 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
9207 | 9207 |
9208 SSLSocketDataProvider ssl(true, OK); | 9208 SSLSocketDataProvider ssl(true, OK); |
9209 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 9209 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
9210 ssl.next_proto = "spdy/2"; | 9210 ssl.next_proto = "spdy/2.1"; |
9211 ssl.was_npn_negotiated = true; | 9211 ssl.was_npn_negotiated = true; |
9212 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 9212 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
9213 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9213 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
9214 | 9214 |
9215 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9215 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
9216 | 9216 |
9217 // Set up an initial SpdySession in the pool to reuse. | 9217 // Set up an initial SpdySession in the pool to reuse. |
9218 HostPortPair host_port_pair("www.google.com", 443); | 9218 HostPortPair host_port_pair("www.google.com", 443); |
9219 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 9219 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
9220 scoped_refptr<SpdySession> spdy_session = | 9220 scoped_refptr<SpdySession> spdy_session = |
9221 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 9221 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
9222 scoped_refptr<TransportSocketParams> transport_params( | 9222 scoped_refptr<TransportSocketParams> transport_params( |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9637 params.http_auth_handler_factory = | 9637 params.http_auth_handler_factory = |
9638 session_deps.http_auth_handler_factory.get(); | 9638 session_deps.http_auth_handler_factory.get(); |
9639 params.http_server_properties = &session_deps.http_server_properties; | 9639 params.http_server_properties = &session_deps.http_server_properties; |
9640 params.net_log = session_deps.net_log; | 9640 params.net_log = session_deps.net_log; |
9641 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 9641 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
9642 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9642 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
9643 pool_peer.DisableDomainAuthenticationVerification(); | 9643 pool_peer.DisableDomainAuthenticationVerification(); |
9644 | 9644 |
9645 SSLSocketDataProvider ssl(true, OK); | 9645 SSLSocketDataProvider ssl(true, OK); |
9646 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 9646 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
9647 ssl.next_proto = "spdy/2"; | 9647 ssl.next_proto = "spdy/2.1"; |
9648 ssl.was_npn_negotiated = true; | 9648 ssl.was_npn_negotiated = true; |
9649 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 9649 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
9650 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9650 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
9651 | 9651 |
9652 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( | 9652 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( |
9653 "https://www.google.com", false, 1, LOWEST)); | 9653 "https://www.google.com", false, 1, LOWEST)); |
9654 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( | 9654 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( |
9655 "https://www.gmail.com", false, 3, LOWEST)); | 9655 "https://www.gmail.com", false, 3, LOWEST)); |
9656 MockWrite spdy_writes[] = { | 9656 MockWrite spdy_writes[] = { |
9657 CreateMockWrite(*host1_req, 1), | 9657 CreateMockWrite(*host1_req, 1), |
9658 CreateMockWrite(*host2_req, 4), | 9658 CreateMockWrite(*host2_req, 4), |
9659 }; | 9659 }; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9791 params.http_auth_handler_factory = | 9791 params.http_auth_handler_factory = |
9792 session_deps.http_auth_handler_factory.get(); | 9792 session_deps.http_auth_handler_factory.get(); |
9793 params.http_server_properties = &session_deps.http_server_properties; | 9793 params.http_server_properties = &session_deps.http_server_properties; |
9794 params.net_log = session_deps.net_log; | 9794 params.net_log = session_deps.net_log; |
9795 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 9795 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
9796 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9796 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
9797 pool_peer.DisableDomainAuthenticationVerification(); | 9797 pool_peer.DisableDomainAuthenticationVerification(); |
9798 | 9798 |
9799 SSLSocketDataProvider ssl(true, OK); | 9799 SSLSocketDataProvider ssl(true, OK); |
9800 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 9800 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
9801 ssl.next_proto = "spdy/2"; | 9801 ssl.next_proto = "spdy/2.1"; |
9802 ssl.was_npn_negotiated = true; | 9802 ssl.was_npn_negotiated = true; |
9803 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 9803 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
9804 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9804 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
9805 | 9805 |
9806 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( | 9806 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( |
9807 "https://www.google.com", false, 1, LOWEST)); | 9807 "https://www.google.com", false, 1, LOWEST)); |
9808 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( | 9808 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( |
9809 "https://www.gmail.com", false, 3, LOWEST)); | 9809 "https://www.gmail.com", false, 3, LOWEST)); |
9810 MockWrite spdy_writes[] = { | 9810 MockWrite spdy_writes[] = { |
9811 CreateMockWrite(*host1_req, 1), | 9811 CreateMockWrite(*host1_req, 1), |
9812 CreateMockWrite(*host2_req, 4), | 9812 CreateMockWrite(*host2_req, 4), |
9813 }; | 9813 }; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9928 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9928 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9929 | 9929 |
9930 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9930 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9931 | 9931 |
9932 EXPECT_EQ(OK, out.rv); | 9932 EXPECT_EQ(OK, out.rv); |
9933 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9933 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9934 EXPECT_EQ("hello world", out.response_data); | 9934 EXPECT_EQ("hello world", out.response_data); |
9935 } | 9935 } |
9936 | 9936 |
9937 } // namespace net | 9937 } // namespace net |
OLD | NEW |