src/net/quic/quic_network_transaction_unittest.cc
// Makes sure the CONNECT request packet for a QUIC proxy contains the correct
// HTTP/2 stream dependency and weights given the request priority.
Makes sure the CONNECT request packet for a QUIC proxy contains the correct
HTTP/2 stream dependency and weights given the request priority.
Makes sure the CONNECT request packet for a QUIC proxy contains the correct HTTP / 2 stream dependency and weights given the request priority .
TEST_P(QuicNetworkTransactionTest, QuicProxyMultipleRequestsError) {
  session_params_.enable_quic = true;
  session_params_.enable_quic_proxies_for_https_urls = true;
  proxy_resolution_service_ =
      ConfiguredProxyResolutionService::CreateFixedFromPacResult(
          "QUIC proxy.example.org:70", TRAFFIC_ANNOTATION_FOR_TESTS);
  const RequestPriority kRequestPriority = MEDIUM;
  const RequestPriority kRequestPriority2 = LOWEST;
  MockQuicData mock_quic_data(version_);
  if (VersionUsesHttp3(version_.transport_version)) {
    mock_quic_data.AddWrite(ASYNC, ConstructInitialSettingsPacket(1));
    mock_quic_data.AddWrite(SYNCHRONOUS, ERR_FAILED);
  } else {
    mock_quic_data.AddWrite(
        SYNCHRONOUS, ConstructClientRequestHeadersPacket(
                         1, GetNthClientInitiatedBidirectionalStreamId(0), true,
                         false, HttpProxyConnectJob::kH2QuicTunnelPriority,
                         ConnectRequestHeaders("mail.example.org:443"), 0));
  }
  mock_quic_data.AddRead(ASYNC, ERR_CONNECTION_FAILED);
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  MockQuicData mock_quic_data2(version_);
  mock_quic_data2.AddConnect(SYNCHRONOUS, ERR_FAILED);
  mock_quic_data2.AddSocketDataToFactory(&socket_factory_);
  int original_max_sockets_per_group =
      ClientSocketPoolManager::max_sockets_per_group(
          HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL);
  ClientSocketPoolManager::set_max_sockets_per_group(
      HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL, 1);
  int original_max_sockets_per_pool =
      ClientSocketPoolManager::max_sockets_per_pool(
          HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL);
  ClientSocketPoolManager::set_max_sockets_per_pool(
      HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL, 1);
  CreateSession();
  request_.url = GURL("https://mail.example.org/");
  HttpNetworkTransaction trans(kRequestPriority, session_.get());
  TestCompletionCallback callback;
  int rv = trans.Start(&request_, callback.callback(), net_log_.bound());
  EXPECT_EQ(ERR_IO_PENDING, rv);
  HttpRequestInfo request2;
  request2.url = GURL("https://mail.example.org/some/other/path/");
  request2.traffic_annotation =
      net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
  HttpNetworkTransaction trans2(kRequestPriority2, session_.get());
  TestCompletionCallback callback2;
  int rv2 = trans2.Start(&request2, callback2.callback(), net_log_.bound());
  EXPECT_EQ(ERR_IO_PENDING, rv2);
  EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, callback.WaitForResult());
  EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
  EXPECT_EQ(ERR_FAILED, callback2.WaitForResult());
  ClientSocketPoolManager::set_max_sockets_per_pool(
      HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL,
      original_max_sockets_per_pool);
  ClientSocketPoolManager::set_max_sockets_per_group(
      HttpNetworkSession::SocketPoolType::NORMAL_SOCKET_POOL,
      original_max_sockets_per_group);
}
TEST_P ( QuicNetworkTransactionTest , QuicProxyMultipleRequestsError ) { session_params_ . enable_quic = true ; session_params_ . enable_quic_proxies_for_https_urls = true ; proxy_resolution_service_ = ConfiguredProxyResolutionService :: CreateFixedFromPacResult ( " " , TRAFFIC_ANNOTATION_FOR_TESTS ) ; const RequestPriority kRequestPriority = MEDIUM ; const RequestPriority kRequestPriority2 = LOWEST ; MockQuicData mock_quic_data ( version_ ) ; if ( VersionUsesHttp3 ( version_ . transport_version ) ) { mock_quic_data . AddWrite ( ASYNC , ConstructInitialSettingsPacket ( 1 ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ERR_FAILED ) ; } else { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , false , HttpProxyConnectJob :: kH2QuicTunnelPriority , ConnectRequestHeaders ( " " ) , 0 ) ) ; } mock_quic_data . AddRead ( ASYNC , ERR_CONNECTION_FAILED ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; MockQuicData mock_quic_data2 ( version_ ) ; mock_quic_data2 . AddConnect ( SYNCHRONOUS , ERR_FAILED ) ; mock_quic_data2 . AddSocketDataToFactory ( & socket_factory_ ) ; int original_max_sockets_per_group = ClientSocketPoolManager :: max_sockets_per_group ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL ) ; ClientSocketPoolManager :: set_max_sockets_per_group ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL , 1 ) ; int original_max_sockets_per_pool = ClientSocketPoolManager :: max_sockets_per_pool ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL ) ; ClientSocketPoolManager :: set_max_sockets_per_pool ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL , 1 ) ; CreateSession ( ) ; request_ . url = GURL ( " " ) ; HttpNetworkTransaction trans ( kRequestPriority , session_ . get ( ) ) ; TestCompletionCallback callback ; int rv = trans . Start ( & request_ , callback . callback ( ) , net_log_ . bound ( ) ) ; EXPECT_EQ ( ERR_IO_PENDING , rv ) ; HttpRequestInfo request2 ; request2 . url = GURL ( " " ) ; request2 . traffic_annotation = net :: MutableNetworkTrafficAnnotationTag ( TRAFFIC_ANNOTATION_FOR_TESTS ) ; HttpNetworkTransaction trans2 ( kRequestPriority2 , session_ . get ( ) ) ; TestCompletionCallback callback2 ; int rv2 = trans2 . Start ( & request2 , callback2 . callback ( ) , net_log_ . bound ( ) ) ; EXPECT_EQ ( ERR_IO_PENDING , rv2 ) ; EXPECT_EQ ( ERR_QUIC_PROTOCOL_ERROR , callback . WaitForResult ( ) ) ; EXPECT_TRUE ( mock_quic_data . AllWriteDataConsumed ( ) ) ; EXPECT_EQ ( ERR_FAILED , callback2 . WaitForResult ( ) ) ; ClientSocketPoolManager :: set_max_sockets_per_pool ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL , original_max_sockets_per_pool ) ; ClientSocketPoolManager :: set_max_sockets_per_group ( HttpNetworkSession :: SocketPoolType :: NORMAL_SOCKET_POOL , original_max_sockets_per_group ) ; }
Makes sure the CONNECT request packet for a QUIC proxy contains the correct
HTTP/2 stream dependency and weights given the request priority.
Makes sure the CONNECT request packet for a QUIC proxy contains the correct HTTP / 2 stream dependency and weights given the request priority .
// This should never be reached. // Second connection attempt just fails - result doesn't really matter.