src/net/quic/quic_network_transaction_unittest.cc
// Pool to existing session with matching quic::QuicServerId
// even if alternative service destination is different.
Pool to existing session with matching quic::QuicServerId
even if alternative service destination is different.
Pool to existing session with matching quic :: QuicServerId even if alternative service destination is different .
TEST_P(QuicNetworkTransactionTest, PoolByOrigin) {
  context_.params()->allow_remote_alt_svc = true;
  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", "https", "/")));
  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.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(1), false,
          true, GetRequestHeaders("GET", "https", "/"),
          GetNthClientInitiatedBidirectionalStreamId(0)));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 3, GetNthClientInitiatedBidirectionalStreamId(1), false, false,
                 GetResponseHeaders("200 OK")));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 4, GetNthClientInitiatedBidirectionalStreamId(1), false, true,
                 header + "hello!"));
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientAckAndConnectionClosePacket(packet_num++, 4, 3, 1));
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);  
  mock_quic_data.AddRead(ASYNC, 0);               
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  AddHangingNonAlternateProtocolSocketData();
  AddHangingNonAlternateProtocolSocketData();
  CreateSession();
  QuicStreamFactoryPeer::SetAlarmFactory(
      session_->quic_stream_factory(),
      std::make_unique<QuicChromiumAlarmFactory>(quic_task_runner_.get(),
                                                 context_.clock()));
  const char destination1[] = "first.example.com";
  const char destination2[] = "second.example.com";
  url::SchemeHostPort server(request_.url);
  AlternativeService alternative_service(kProtoQUIC, destination1, 443);
  base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
  http_server_properties_->SetQuicAlternativeService(
      server, NetworkIsolationKey(), alternative_service, expiration,
      supported_versions_);
  SendRequestAndExpectQuicResponse("hello!");
  alternative_service = AlternativeService(kProtoQUIC, destination2, 443);
  http_server_properties_->SetQuicAlternativeService(
      server, NetworkIsolationKey(), alternative_service, expiration,
      supported_versions_);
  SendRequestAndExpectQuicResponse("hello!");
}
TEST_P ( QuicNetworkTransactionTest , PoolByOrigin ) { context_ . params ( ) -> allow_remote_alt_svc = true ; 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 . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , true , GetRequestHeaders ( " " , " " , " " ) , GetNthClientInitiatedBidirectionalStreamId ( 0 ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 3 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , false , GetResponseHeaders ( " " ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 4 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , true , header + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckAndConnectionClosePacket ( packet_num ++ , 4 , 3 , 1 ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; AddHangingNonAlternateProtocolSocketData ( ) ; AddHangingNonAlternateProtocolSocketData ( ) ; CreateSession ( ) ; QuicStreamFactoryPeer :: SetAlarmFactory ( session_ -> quic_stream_factory ( ) , std :: make_unique < QuicChromiumAlarmFactory > ( quic_task_runner_ . get ( ) , context_ . clock ( ) ) ) ; const char destination1 [ ] = " " ; const char destination2 [ ] = " " ; url :: SchemeHostPort server ( request_ . url ) ; AlternativeService alternative_service ( kProtoQUIC , destination1 , 443 ) ; base :: Time expiration = base :: Time :: Now ( ) + base :: TimeDelta :: FromDays ( 1 ) ; http_server_properties_ -> SetQuicAlternativeService ( server , NetworkIsolationKey ( ) , alternative_service , expiration , supported_versions_ ) ; SendRequestAndExpectQuicResponse ( " " ) ; alternative_service = AlternativeService ( kProtoQUIC , destination2 , 443 ) ; http_server_properties_ -> SetQuicAlternativeService ( server , NetworkIsolationKey ( ) , alternative_service , expiration , supported_versions_ ) ; SendRequestAndExpectQuicResponse ( " " ) ; }
Pool to existing session with matching quic::QuicServerId
even if alternative service destination is different.
Pool to existing session with matching quic :: QuicServerId even if alternative service destination is different .
// First request. // Second request. // No more data to read // EOF // Set up alternative service entry to destination1. // First request opens connection to |destination1| // with quic::QuicServerId.host() == kDefaultServerHostName. // Set up alternative service entry to a different destination. // Second request pools to existing connection with same quic::QuicServerId, // even though alternative service destination is different.