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

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: Addressed comments. 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 bool UnencryptedHTTP11Flag[2] = {false, true};
606 for (auto loadFlag : UnencryptedHTTP11Flag) {
607 socket_factory_.ResetNextMockIndexes();
608
609 request_.load_flags = loadFlag ? LOAD_UNENCRYPTED_HTTP11 : 0;
610 scoped_ptr<HttpNetworkTransaction> trans(
611 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get()));
612 TestCompletionCallback callback;
613 int rv =
614 trans.get()->Start(&request_, callback.callback(), net_log_.bound());
615 EXPECT_EQ(ERR_IO_PENDING, rv) << loadFlag;
616 // When LOAD_ONLY_HTTP11 is enabled, connection is established
617 // because QUIC is not used.
618 EXPECT_EQ(loadFlag, OK == callback.WaitForResult()) << loadFlag;
619 }
620 }
621
586 TEST_P(QuicNetworkTransactionTest, 622 TEST_P(QuicNetworkTransactionTest,
587 DontUseAlternateProtocolWithBadProbabilityForQuic) { 623 DontUseAlternateProtocolWithBadProbabilityForQuic) {
588 MockRead http_reads[] = { 624 MockRead http_reads[] = {
589 MockRead("HTTP/1.1 200 OK\r\n"), 625 MockRead("HTTP/1.1 200 OK\r\n"),
590 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"), 626 MockRead("Alternate-Protocol: 443:quic,p=2\r\n\r\n"),
591 MockRead("hello world"), 627 MockRead("hello world"),
592 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), 628 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
593 MockRead(ASYNC, OK) 629 MockRead(ASYNC, OK)
594 }; 630 };
595 631
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 nullptr, 1100 nullptr,
1065 net_log_.bound()); 1101 net_log_.bound());
1066 1102
1067 CreateSessionWithNextProtos(); 1103 CreateSessionWithNextProtos();
1068 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); 1104 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
1069 SendRequestAndExpectHttpResponse("hello world"); 1105 SendRequestAndExpectHttpResponse("hello world");
1070 } 1106 }
1071 1107
1072 } // namespace test 1108 } // namespace test
1073 } // namespace net 1109 } // 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