Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: net/quic/chromium/quic_network_transaction_unittest.cc

Issue 2260623002: Race TCP connection to proxies with QUIC connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 #include <ostream> 6 #include <ostream>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "net/base/chunked_upload_data_stream.h" 16 #include "net/base/chunked_upload_data_stream.h"
17 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
18 #include "net/base/test_proxy_delegate.h"
18 #include "net/cert/ct_policy_enforcer.h" 19 #include "net/cert/ct_policy_enforcer.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/dns/mock_host_resolver.h" 22 #include "net/dns/mock_host_resolver.h"
22 #include "net/http/http_auth_handler_factory.h" 23 #include "net/http/http_auth_handler_factory.h"
23 #include "net/http/http_network_session.h" 24 #include "net/http/http_network_session.h"
24 #include "net/http/http_network_transaction.h" 25 #include "net/http/http_network_transaction.h"
25 #include "net/http/http_server_properties_impl.h" 26 #include "net/http/http_server_properties_impl.h"
26 #include "net/http/http_stream.h" 27 #include "net/http/http_stream.h"
27 #include "net/http/http_stream_factory.h" 28 #include "net/http/http_stream_factory.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 EXPECT_THAT(callback.WaitForResult(), IsOk()); 566 EXPECT_THAT(callback.WaitForResult(), IsOk());
566 } 567 }
567 568
568 void SendRequestAndExpectHttpResponse(const std::string& expected) { 569 void SendRequestAndExpectHttpResponse(const std::string& expected) {
569 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get()); 570 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
570 RunTransaction(&trans); 571 RunTransaction(&trans);
571 CheckWasHttpResponse(&trans); 572 CheckWasHttpResponse(&trans);
572 CheckResponseData(&trans, expected); 573 CheckResponseData(&trans, expected);
573 } 574 }
574 575
576 void SendRequestAndExpectHttpResponseFromProxy(const std::string& expected,
577 bool used_proxy,
578 uint16_t port) {
579 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
580 HeadersHandler headers_handler;
581 trans.SetBeforeHeadersSentCallback(
582 base::Bind(&HeadersHandler::OnBeforeHeadersSent,
583 base::Unretained(&headers_handler)));
584 RunTransaction(&trans);
585 CheckWasHttpResponse(&trans);
586 CheckResponsePort(&trans, port);
587 CheckResponseData(&trans, expected);
588 EXPECT_EQ(used_proxy, headers_handler.was_proxied());
589 }
590
575 void SendRequestAndExpectQuicResponse(const std::string& expected) { 591 void SendRequestAndExpectQuicResponse(const std::string& expected) {
576 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, false, 443); 592 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, false, 443);
577 } 593 }
578 594
579 void SendRequestAndExpectQuicResponseFromProxyOnPort( 595 void SendRequestAndExpectQuicResponseFromProxyOnPort(
580 const std::string& expected, 596 const std::string& expected,
581 uint16_t port) { 597 uint16_t port) {
582 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port); 598 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port);
583 } 599 }
584 600
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 void AddHangingNonAlternateProtocolSocketData() { 640 void AddHangingNonAlternateProtocolSocketData() {
625 std::unique_ptr<StaticSocketDataProvider> hanging_data; 641 std::unique_ptr<StaticSocketDataProvider> hanging_data;
626 hanging_data.reset(new StaticSocketDataProvider()); 642 hanging_data.reset(new StaticSocketDataProvider());
627 MockConnect hanging_connect(SYNCHRONOUS, ERR_IO_PENDING); 643 MockConnect hanging_connect(SYNCHRONOUS, ERR_IO_PENDING);
628 hanging_data->set_connect_data(hanging_connect); 644 hanging_data->set_connect_data(hanging_connect);
629 hanging_data_.push_back(std::move(hanging_data)); 645 hanging_data_.push_back(std::move(hanging_data));
630 socket_factory_.AddSocketDataProvider(hanging_data_.back().get()); 646 socket_factory_.AddSocketDataProvider(hanging_data_.back().get());
631 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); 647 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
632 } 648 }
633 649
650 // Fetches two non-cryptographic URL requests via a HTTPS proxy with a QUIC
651 // alternative proxy. Verifies that if the alternative proxy job returns
652 // |error_code|, the request is fetched successfully by the main job.
653 void TestAlternativeProxy(int error_code) {
654 // Use a non-cryptographic scheme for the request URL since this request
655 // will be fetched via proxy with QUIC as the alternative service.
656 request_.url = GURL("http://example.org/");
657 // Data for the alternative proxy server job.
658 MockRead quic_reads[] = {
659 MockRead(SYNCHRONOUS, error_code),
660 };
661
662 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads),
663 nullptr, 0);
664 socket_factory_.AddSocketDataProvider(&quic_data);
665
666 // Main job succeeds and the alternative job fails.
667 // Add data for two requests that will be read by the main job.
668 MockRead http_reads_1[] = {
669 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"),
670 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
671 MockRead(ASYNC, OK)};
672
673 MockRead http_reads_2[] = {
674 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"),
675 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
676 MockRead(ASYNC, OK)};
677
678 StaticSocketDataProvider http_data_1(http_reads_1, arraysize(http_reads_1),
679 nullptr, 0);
680 StaticSocketDataProvider http_data_2(http_reads_2, arraysize(http_reads_2),
681 nullptr, 0);
682 socket_factory_.AddSocketDataProvider(&http_data_1);
683 socket_factory_.AddSocketDataProvider(&http_data_2);
684 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
685 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
686
687 TestProxyDelegate test_proxy_delegate;
688 // Proxy URL is different from the request URL.
689 test_proxy_delegate.SetAlternativeProxy(
690 ProxyServer::FromPacString("QUIC myproxy.org:443"));
691
692 params_.proxy_delegate = &test_proxy_delegate;
693 proxy_service_ =
694 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443");
695
696 CreateSession();
697 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_valid());
698
699 // The first request should be fetched via the HTTPS proxy.
700 SendRequestAndExpectHttpResponseFromProxy("hello from http", true, 443);
701
702 // Even through the alternative proxy server job failed, the proxy should
703 // not be marked as bad since the main job succeeded.
704 EXPECT_TRUE(session_->proxy_service()->proxy_retry_info().empty());
705
706 // The alternative proxy server should no longer be in use.
707 EXPECT_FALSE(test_proxy_delegate.alternative_proxy_server().is_valid());
708
709 // Verify that the second request completes successfully, and the
710 // alternative proxy server job is not started.
711 SendRequestAndExpectHttpResponseFromProxy("hello from http", true, 443);
712 }
713
634 MockClock* clock_; // Owned by QuicStreamFactory after CreateSession. 714 MockClock* clock_; // Owned by QuicStreamFactory after CreateSession.
635 QuicTestPacketMaker client_maker_; 715 QuicTestPacketMaker client_maker_;
636 QuicTestPacketMaker server_maker_; 716 QuicTestPacketMaker server_maker_;
637 std::unique_ptr<HttpNetworkSession> session_; 717 std::unique_ptr<HttpNetworkSession> session_;
638 MockClientSocketFactory socket_factory_; 718 MockClientSocketFactory socket_factory_;
639 ProofVerifyDetailsChromium verify_details_; 719 ProofVerifyDetailsChromium verify_details_;
640 MockCryptoClientStreamFactory crypto_client_stream_factory_; 720 MockCryptoClientStreamFactory crypto_client_stream_factory_;
641 MockHostResolver host_resolver_; 721 MockHostResolver host_resolver_;
642 MockCertVerifier cert_verifier_; 722 MockCertVerifier cert_verifier_;
643 TransportSecurityState transport_security_state_; 723 TransportSecurityState transport_security_state_;
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 1661
1582 mock_quic_data.AddSocketDataToFactory(&socket_factory_); 1662 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
1583 1663
1584 AddHangingNonAlternateProtocolSocketData(); 1664 AddHangingNonAlternateProtocolSocketData();
1585 CreateSession(); 1665 CreateSession();
1586 1666
1587 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo(). 1667 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo().
1588 SendRequestAndExpectHttpResponse("hello world"); 1668 SendRequestAndExpectHttpResponse("hello world");
1589 } 1669 }
1590 1670
1671 // Tests that the connection to an HTTPS proxy is raced with an available
1672 // alternative proxy server.
1673 TEST_P(QuicNetworkTransactionTest, QuicProxyWithRacing) {
1674 proxy_service_ =
1675 ProxyService::CreateFixedFromPacResult("HTTPS mail.example.org:443");
1676
1677 MockQuicData mock_quic_data;
1678 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
1679 1, kClientDataStreamId1, true, true,
1680 GetRequestHeaders("GET", "http", "/")));
1681 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket(
1682 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK")));
1683 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1,
1684 false, true, 0, "hello!"));
1685 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1));
1686 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read
1687 mock_quic_data.AddRead(ASYNC, 0); // EOF
1688
1689 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
1690
1691 // There is no need to set up main job, because no attempt will be made to
1692 // speak to the proxy over TCP.
1693 request_.url = GURL("http://mail.example.org/");
1694 params_.enable_quic_alternative_service_with_different_host = false;
1695 TestProxyDelegate test_proxy_delegate;
1696 const HostPortPair host_port_pair("mail.example.org", 443);
1697
1698 test_proxy_delegate.SetAlternativeProxy(
1699 ProxyServer::FromPacString("QUIC mail.example.org:443"));
1700 params_.proxy_delegate = &test_proxy_delegate;
1701 CreateSession();
1702 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
1703
1704 // The main job needs to hang in order to guarantee that the alternative
1705 // proxy server job will "win".
1706 AddHangingNonAlternateProtocolSocketData();
1707
1708 SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 443);
1709
1710 // Verify that the alternative proxy server is not marked as broken.
1711 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
1712
1713 // Verify that the proxy server is not marked as broken.
1714 EXPECT_TRUE(session_->proxy_service()->proxy_retry_info().empty());
1715 }
1716
1591 TEST_P(QuicNetworkTransactionTest, HungAlternativeService) { 1717 TEST_P(QuicNetworkTransactionTest, HungAlternativeService) {
1592 crypto_client_stream_factory_.set_handshake_mode( 1718 crypto_client_stream_factory_.set_handshake_mode(
1593 MockCryptoClientStream::COLD_START); 1719 MockCryptoClientStream::COLD_START);
1594 1720
1595 MockWrite http_writes[] = { 1721 MockWrite http_writes[] = {
1596 MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n"), 1722 MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n"),
1597 MockWrite(SYNCHRONOUS, 1, "Host: mail.example.org\r\n"), 1723 MockWrite(SYNCHRONOUS, 1, "Host: mail.example.org\r\n"),
1598 MockWrite(SYNCHRONOUS, 2, "Connection: keep-alive\r\n\r\n")}; 1724 MockWrite(SYNCHRONOUS, 2, "Connection: keep-alive\r\n\r\n")};
1599 1725
1600 MockRead http_reads[] = { 1726 MockRead http_reads[] = {
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 AddressList address; 2320 AddressList address;
2195 std::unique_ptr<HostResolver::Request> request; 2321 std::unique_ptr<HostResolver::Request> request;
2196 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), 2322 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(),
2197 &request, net_log_.bound()); 2323 &request, net_log_.bound());
2198 2324
2199 CreateSession(); 2325 CreateSession();
2200 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); 2326 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
2201 SendRequestAndExpectHttpResponse("hello world"); 2327 SendRequestAndExpectHttpResponse("hello world");
2202 } 2328 }
2203 2329
2330 // For an alternative proxy that supports QUIC, test that the request is
2331 // successfully fetched by the main job when the alternate proxy job encounters
2332 // an error.
2333 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxySocketNotConnected) {
2334 TestAlternativeProxy(ERR_SOCKET_NOT_CONNECTED);
2335 }
2336 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyConnectionFailed) {
2337 TestAlternativeProxy(ERR_CONNECTION_FAILED);
2338 }
2339 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyConnectionTimedOut) {
2340 TestAlternativeProxy(ERR_CONNECTION_TIMED_OUT);
2341 }
2342 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyConnectionRefused) {
2343 TestAlternativeProxy(ERR_CONNECTION_REFUSED);
2344 }
2345 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyQuicHandshakeFailed) {
2346 TestAlternativeProxy(ERR_QUIC_HANDSHAKE_FAILED);
2347 }
2348 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyQuicProtocolError) {
2349 TestAlternativeProxy(ERR_QUIC_PROTOCOL_ERROR);
2350 }
2351 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyIOPending) {
2352 TestAlternativeProxy(ERR_IO_PENDING);
2353 }
2354 TEST_P(QuicNetworkTransactionTest, BrokenAlternativeProxyAddressUnreachable) {
2355 TestAlternativeProxy(ERR_ADDRESS_UNREACHABLE);
2356 }
2357
2358 TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnectProxy) {
2359 MockQuicData mock_quic_data;
2360 mock_quic_data.AddSynchronousRead(ConstructServerConnectionClosePacket(1));
2361 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
2362 1, kClientDataStreamId1, true, true,
2363 GetRequestHeaders("GET", "https", "/")));
2364 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1));
2365 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
2366
2367 // When the QUIC connection fails, we will try the request again over HTTP.
2368 MockRead http_reads[] = {
2369 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternativeServiceHeader),
2370 MockRead("hello world"),
2371 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
2372 MockRead(ASYNC, OK)};
2373
2374 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
2375 0);
2376 socket_factory_.AddSocketDataProvider(&http_data);
2377 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
2378
2379 TestProxyDelegate test_proxy_delegate;
2380 const HostPortPair host_port_pair("myproxy.org", 443);
2381 test_proxy_delegate.SetAlternativeProxy(
2382 ProxyServer::FromPacString("QUIC myproxy.org:443"));
2383 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
2384
2385 params_.proxy_delegate = &test_proxy_delegate;
2386 proxy_service_ =
2387 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443");
2388 request_.url = GURL("http://mail.example.org/");
2389
2390 // In order for a new QUIC session to be established via alternate-protocol
2391 // without racing an HTTP connection, we need the host resolution to happen
2392 // synchronously.
2393 host_resolver_.set_synchronous_mode(true);
2394 host_resolver_.rules()->AddIPLiteralRule("myproxy.org", "192.168.0.1", "");
2395 HostResolver::RequestInfo info(HostPortPair("myproxy.org", 443));
2396 AddressList address;
2397 std::unique_ptr<HostResolver::Request> request;
2398 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(),
2399 &request, net_log_.bound());
2400
2401 CreateSession();
2402 SendRequestAndExpectHttpResponseFromProxy("hello world", true, 443);
2403 EXPECT_FALSE(test_proxy_delegate.alternative_proxy_server().is_valid());
2404 EXPECT_TRUE(session_->proxy_service()->proxy_retry_info().empty());
2405 }
2406
2204 TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) { 2407 TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
2205 client_maker_.set_hostname("www.example.org"); 2408 client_maker_.set_hostname("www.example.org");
2206 EXPECT_FALSE( 2409 EXPECT_FALSE(
2207 test_socket_performance_watcher_factory_.rtt_notification_received()); 2410 test_socket_performance_watcher_factory_.rtt_notification_received());
2208 MockQuicData mock_quic_data; 2411 MockQuicData mock_quic_data;
2209 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( 2412 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
2210 1, kClientDataStreamId1, true, true, 2413 1, kClientDataStreamId1, true, true,
2211 GetRequestHeaders("GET", "https", "/"))); 2414 GetRequestHeaders("GET", "https", "/")));
2212 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( 2415 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket(
2213 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); 2416 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK")));
2214 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, 2417 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1,
2215 false, true, 0, "hello!")); 2418 false, true, 0, "hello!"));
2216 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); 2419 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1));
2217 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data. 2420 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data.
2218 mock_quic_data.AddSocketDataToFactory(&socket_factory_); 2421 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
2219 2422
2220 request_.url = GURL("https://www.example.org:443"); 2423 request_.url = GURL("https://www.example.org:443");
2221 AddHangingNonAlternateProtocolSocketData(); 2424 AddHangingNonAlternateProtocolSocketData();
2222 CreateSession(); 2425 CreateSession();
2223 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); 2426 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE);
2224 SendRequestAndExpectQuicResponse("hello!"); 2427 SendRequestAndExpectQuicResponse("hello!");
2225 EXPECT_TRUE( 2428 EXPECT_TRUE(
2226 test_socket_performance_watcher_factory_.rtt_notification_received()); 2429 test_socket_performance_watcher_factory_.rtt_notification_received());
2227 } 2430 }
2228 2431
2432 TEST_P(QuicNetworkTransactionTest, QuicUploadToAlternativeProxyServer) {
2433 proxy_service_ =
2434 ProxyService::CreateFixedFromPacResult("HTTPS mail.example.org:443");
2435
2436 TestProxyDelegate test_proxy_delegate;
2437 const HostPortPair host_port_pair("mail.example.org", 443);
2438
2439 test_proxy_delegate.SetAlternativeProxy(
2440 ProxyServer::FromPacString("QUIC mail.example.org:443"));
2441 params_.proxy_delegate = &test_proxy_delegate;
2442
2443 request_.url = GURL("http://mail.example.org/");
2444
2445 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)};
2446 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)};
2447 SequencedSocketData socket_data(reads, arraysize(reads), writes,
2448 arraysize(writes));
2449 socket_factory_.AddSocketDataProvider(&socket_data);
2450
2451 // The non-alternate protocol job needs to hang in order to guarantee that
2452 // the alternate-protocol job will "win".
2453 AddHangingNonAlternateProtocolSocketData();
2454
2455 CreateSession();
2456 request_.method = "POST";
2457 ChunkedUploadDataStream upload_data(0);
2458 upload_data.AppendData("1", 1, true);
2459
2460 request_.upload_data_stream = &upload_data;
2461
2462 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
2463 TestCompletionCallback callback;
2464 int rv = trans.Start(&request_, callback.callback(), net_log_.bound());
2465 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
2466 EXPECT_NE(OK, callback.WaitForResult());
2467
2468 // Verify that the alternative proxy server is not marked as broken.
2469 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
2470
2471 // Verify that the proxy server is not marked as broken.
2472 EXPECT_TRUE(session_->proxy_service()->proxy_retry_info().empty());
2473 }
2474
2229 TEST_P(QuicNetworkTransactionTest, QuicUpload) { 2475 TEST_P(QuicNetworkTransactionTest, QuicUpload) {
2230 params_.origins_to_force_quic_on.insert( 2476 params_.origins_to_force_quic_on.insert(
2231 HostPortPair::FromString("mail.example.org:443")); 2477 HostPortPair::FromString("mail.example.org:443"));
2232 2478
2233 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; 2479 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)};
2234 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; 2480 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)};
2235 SequencedSocketData socket_data(reads, arraysize(reads), writes, 2481 SequencedSocketData socket_data(reads, arraysize(reads), writes,
2236 arraysize(writes)); 2482 arraysize(writes));
2237 socket_factory_.AddSocketDataProvider(&socket_data); 2483 socket_factory_.AddSocketDataProvider(&socket_data);
2238 2484
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 AddHangingSocketData(); 3021 AddHangingSocketData();
2776 3022
2777 SendRequestAndExpectQuicResponse(origin1_); 3023 SendRequestAndExpectQuicResponse(origin1_);
2778 SendRequestAndExpectQuicResponse(origin2_); 3024 SendRequestAndExpectQuicResponse(origin2_);
2779 3025
2780 EXPECT_TRUE(AllDataConsumed()); 3026 EXPECT_TRUE(AllDataConsumed());
2781 } 3027 }
2782 3028
2783 } // namespace test 3029 } // namespace test
2784 } // namespace net 3030 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698