src/net/quic/quic_network_transaction_unittest.cc
// Sends a CONNECT request to a QUIC proxy and receive a 500 response.
Sends a CONNECT request to a QUIC proxy and receive a 500 response.
Sends a CONNECT request to a QUIC proxy and receive a 500 response .
TEST_P(QuicNetworkTransactionTest, QuicProxyConnectFailure) {
  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);
  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, client_maker_->MakePriorityPacket(
                         packet_num++, true,
                         GetNthClientInitiatedBidirectionalStreamId(0), 0,
                         ConvertRequestPriorityToQuicPriority(
                             HttpProxyConnectJob::kH2QuicTunnelPriority)));
  }
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0), true,
          false,
          VersionUsesHttp3(version_.transport_version)
              ? MEDIUM
              : HttpProxyConnectJob::kH2QuicTunnelPriority,
          ConnectRequestHeaders("mail.example.org:443"), 0));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 1, GetNthClientInitiatedBidirectionalStreamId(0), false, true,
                 GetResponseHeaders("500")));
  mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING);  
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientAckAndRstPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0),
          quic::QUIC_STREAM_CANCELLED, 1, 1, 1));
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
  CreateSession();
  request_.url = GURL("https://mail.example.org/");
  HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
  TestCompletionCallback callback;
  int rv = trans.Start(&request_, callback.callback(), net_log_.bound());
  EXPECT_EQ(ERR_IO_PENDING, rv);
  EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, callback.WaitForResult());
  EXPECT_TRUE(mock_quic_data.AllReadDataConsumed());
  EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
}
TEST_P ( QuicNetworkTransactionTest , QuicProxyConnectFailure ) { session_params_ . enable_quic = true ; session_params_ . enable_quic_proxies_for_https_urls = true ; 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 , client_maker_ -> MakePriorityPacket ( packet_num ++ , true , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , 0 , ConvertRequestPriorityToQuicPriority ( HttpProxyConnectJob :: kH2QuicTunnelPriority ) ) ) ; } mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , false , VersionUsesHttp3 ( version_ . transport_version ) ? MEDIUM : HttpProxyConnectJob :: kH2QuicTunnelPriority , ConnectRequestHeaders ( " " ) , 0 ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , true , GetResponseHeaders ( " " ) ) ) ; mock_quic_data . AddRead ( SYNCHRONOUS , ERR_IO_PENDING ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckAndRstPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , quic :: QUIC_STREAM_CANCELLED , 1 , 1 , 1 ) ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; socket_factory_ . AddSSLSocketDataProvider ( & ssl_data_ ) ; CreateSession ( ) ; request_ . url = GURL ( " " ) ; HttpNetworkTransaction trans ( DEFAULT_PRIORITY , session_ . get ( ) ) ; TestCompletionCallback callback ; int rv = trans . Start ( & request_ , callback . callback ( ) , net_log_ . bound ( ) ) ; EXPECT_EQ ( ERR_IO_PENDING , rv ) ; EXPECT_EQ ( ERR_TUNNEL_CONNECTION_FAILED , callback . WaitForResult ( ) ) ; EXPECT_TRUE ( mock_quic_data . AllReadDataConsumed ( ) ) ; EXPECT_TRUE ( mock_quic_data . AllWriteDataConsumed ( ) ) ; }
Sends a CONNECT request to a QUIC proxy and receive a 500 response.
Sends a CONNECT request to a QUIC proxy and receive a 500 response .
// No more data to read