src/net/quic/quic_network_transaction_unittest.cc
// Tests that the connection to an HTTPS proxy is raced with an available
// alternative proxy server.
Tests that the connection to an HTTPS proxy is raced with an available
alternative proxy server.
Tests that the connection to an HTTPS proxy is raced with an available alternative proxy server .
TEST_P(QuicNetworkTransactionTest, QuicProxyWithRacing) {
  base::HistogramTester histogram_tester;
  proxy_resolution_service_ =
      ConfiguredProxyResolutionService::CreateFixedFromPacResult(
          "HTTPS mail.example.org:443", TRAFFIC_ANNOTATION_FOR_TESTS);
  MockQuicData mock_quic_data(version_);
  int packet_num = 1;
  if (VersionUsesHttp3(version_.transport_version)) {
    mock_quic_data.AddWrite(SYNCHRONOUS,
                            ConstructInitialSettingsPacket(packet_num++));
  }
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0), true,
          true, GetRequestHeaders("GET", "http", "/")));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 1, GetNthClientInitiatedBidirectionalStreamId(0), false, false,
                 GetResponseHeaders("200 OK")));
  std::string header = ConstructDataHeader(6);
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 2, GetNthClientInitiatedBidirectionalStreamId(0), false, true,
                 header + "hello!"));
  mock_quic_data.AddWrite(SYNCHRONOUS,
                          ConstructClientAckPacket(packet_num++, 2, 1, 1));
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);  
  mock_quic_data.AddRead(ASYNC, 0);               
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  request_.url = GURL("http://mail.example.org/");
  TestProxyDelegate test_proxy_delegate;
  const HostPortPair host_port_pair("mail.example.org", 443);
  test_proxy_delegate.set_alternative_proxy_server(
      ProxyServer::FromPacString("QUIC mail.example.org:443"));
  proxy_resolution_service_->SetProxyDelegate(&test_proxy_delegate);
  CreateSession();
  EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
  AddHangingNonAlternateProtocolSocketData();
  SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 443);
  EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic());
  EXPECT_TRUE(session_->proxy_resolution_service()->proxy_retry_info().empty());
  histogram_tester.ExpectUniqueSample("Net.QuicAlternativeProxy.Usage",
                                      1 ,
                                      1);
}
TEST_P ( QuicNetworkTransactionTest , QuicProxyWithRacing ) { base :: HistogramTester histogram_tester ; proxy_resolution_service_ = ConfiguredProxyResolutionService :: CreateFixedFromPacResult ( " " , TRAFFIC_ANNOTATION_FOR_TESTS ) ; MockQuicData mock_quic_data ( version_ ) ; int packet_num = 1 ; if ( VersionUsesHttp3 ( version_ . transport_version ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructInitialSettingsPacket ( packet_num ++ ) ) ; } mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , true , GetRequestHeaders ( " " , " " , " " ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , false , GetResponseHeaders ( " " ) ) ) ; std :: string header = ConstructDataHeader ( 6 ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 2 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , true , header + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( packet_num ++ , 2 , 1 , 1 ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; request_ . url = GURL ( " " ) ; TestProxyDelegate test_proxy_delegate ; const HostPortPair host_port_pair ( " " , 443 ) ; test_proxy_delegate . set_alternative_proxy_server ( ProxyServer :: FromPacString ( " " ) ) ; proxy_resolution_service_ -> SetProxyDelegate ( & test_proxy_delegate ) ; CreateSession ( ) ; EXPECT_TRUE ( test_proxy_delegate . alternative_proxy_server ( ) . is_quic ( ) ) ; AddHangingNonAlternateProtocolSocketData ( ) ; SendRequestAndExpectQuicResponseFromProxyOnPort ( " " , 443 ) ; EXPECT_TRUE ( test_proxy_delegate . alternative_proxy_server ( ) . is_quic ( ) ) ; EXPECT_TRUE ( session_ -> proxy_resolution_service ( ) -> proxy_retry_info ( ) . empty ( ) ) ; histogram_tester . ExpectUniqueSample ( " " , 1 , 1 ) ; }
Tests that the connection to an HTTPS proxy is raced with an available
alternative proxy server.
Tests that the connection to an HTTPS proxy is raced with an available alternative proxy server .
// No more data to read // EOF // There is no need to set up main job, because no attempt will be made to // speak to the proxy over TCP. // The main job needs to hang in order to guarantee that the alternative // proxy server job will "win". // Verify that the alternative proxy server is not marked as broken. // Verify that the proxy server is not marked as broken. /* ALTERNATIVE_PROXY_USAGE_WON_RACE */