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

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

Issue 981633002: Created new URLRequestContext for secure proxy check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "net/base/capturing_net_log.h" 11 #include "net/base/capturing_net_log.h"
12 #include "net/base/load_flags.h"
12 #include "net/base/net_log_unittest.h" 13 #include "net/base/net_log_unittest.h"
13 #include "net/base/test_completion_callback.h" 14 #include "net/base/test_completion_callback.h"
14 #include "net/cert/mock_cert_verifier.h" 15 #include "net/cert/mock_cert_verifier.h"
15 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
16 #include "net/http/http_auth_handler_factory.h" 17 #include "net/http/http_auth_handler_factory.h"
17 #include "net/http/http_network_session.h" 18 #include "net/http/http_network_session.h"
18 #include "net/http/http_network_transaction.h" 19 #include "net/http/http_network_transaction.h"
19 #include "net/http/http_server_properties_impl.h" 20 #include "net/http/http_server_properties_impl.h"
20 #include "net/http/http_stream.h" 21 #include "net/http/http_stream.h"
21 #include "net/http/http_stream_factory.h" 22 #include "net/http/http_stream_factory.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 socket_factory_.AddSocketDataProvider(&http_data); 577 socket_factory_.AddSocketDataProvider(&http_data);
577 socket_factory_.AddSocketDataProvider(&http_data); 578 socket_factory_.AddSocketDataProvider(&http_data);
578 579
579 params_.alternate_protocol_probability_threshold = .75; 580 params_.alternate_protocol_probability_threshold = .75;
580 CreateSessionWithNextProtos(); 581 CreateSessionWithNextProtos();
581 582
582 SendRequestAndExpectHttpResponse("hello world"); 583 SendRequestAndExpectHttpResponse("hello world");
583 SendRequestAndExpectHttpResponse("hello world"); 584 SendRequestAndExpectHttpResponse("hello world");
584 } 585 }
585 586
587 TEST_P(QuicNetworkTransactionTest, LoadHTTP11) {
588 params_.origin_to_force_quic_on =
589 HostPortPair::FromString("www.google.com:80");
590
591 MockRead http_reads[] = {
592 MockRead("HTTP/1.1 200 OK\r\n"),
593 MockRead(kQuicAlternateProtocol50pctHttpHeader),
594 MockRead("hello world"),
595 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
596 MockRead(ASYNC, OK),
597 };
598
599 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
600 0);
601
602 socket_factory_.AddSocketDataProvider(&http_data);
603 CreateSession();
604
605 for (int i = 0; i <= 1; i++) {
606 socket_factory_.ResetNextMockIndexes();
607
608 if (i == 0) {
609 request_.load_flags = LOAD_UNENCRYPTED_HTTP11;
610 } else if (i == 1) {
611 request_.load_flags = 0;
612 }
613 scoped_ptr<HttpNetworkTransaction> trans(
614 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get()));
615 TestCompletionCallback callback;
616 int rv =
617 trans.get()->Start(&request_, callback.callback(), net_log_.bound());
618 EXPECT_EQ(ERR_IO_PENDING, rv) << i;
619 // When LOAD_ONLY_HTTP11 is enabled, connection is established
620 // because QUIC is not used.
621 EXPECT_EQ(i == 0, OK == callback.WaitForResult()) << i;
622 }
623 }
624
586 TEST_P(QuicNetworkTransactionTest, 625 TEST_P(QuicNetworkTransactionTest,
587 DontUseAlternateProtocolWithBadProbabilityForQuic) { 626 DontUseAlternateProtocolWithBadProbabilityForQuic) {
588 MockRead http_reads[] = { 627 MockRead http_reads[] = {
589 MockRead("HTTP/1.1 200 OK\r\n"), 628 MockRead("HTTP/1.1 200 OK\r\n"),
590 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"), 629 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"),
591 MockRead("hello world"), 630 MockRead("hello world"),
592 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), 631 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
593 MockRead(ASYNC, OK) 632 MockRead(ASYNC, OK)
594 }; 633 };
595 634
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 nullptr, 1103 nullptr,
1065 net_log_.bound()); 1104 net_log_.bound());
1066 1105
1067 CreateSessionWithNextProtos(); 1106 CreateSessionWithNextProtos();
1068 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); 1107 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
1069 SendRequestAndExpectHttpResponse("hello world"); 1108 SendRequestAndExpectHttpResponse("hello world");
1070 } 1109 }
1071 1110
1072 } // namespace test 1111 } // namespace test
1073 } // namespace net 1112 } // namespace net
OLDNEW
« net/http/http_stream_factory_impl_job.cc ('K') | « net/http/http_stream_factory_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698