src/net/quic/quic_network_transaction_unittest.cc
// Checks if a request's specified "user-agent" header shows up correctly in the
// CONNECT request to a QUIC proxy.
Checks if a request's specified "user-agent" header shows up correctly in the
CONNECT request to a QUIC proxy.
Checks if a request ' s specified " user - agent " header shows up correctly in the CONNECT request to a QUIC proxy .
TEST_P(QuicNetworkTransactionTest, QuicProxyUserAgent) {
  const char kConfiguredUserAgent[] = "Configured User-Agent";
  const char kRequestUserAgent[] = "Request User-Agent";
  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)));
  }
  spdy::SpdyHeaderBlock headers = ConnectRequestHeaders("mail.example.org:443");
  headers["user-agent"] = kConfiguredUserAgent;
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          packet_num++, GetNthClientInitiatedBidirectionalStreamId(0), true,
          false,
          VersionUsesHttp3(version_.transport_version)
              ? MEDIUM
              : HttpProxyConnectJob::kH2QuicTunnelPriority,
          std::move(headers), 0));
  mock_quic_data.AddRead(ASYNC, ERR_CONNECTION_FAILED);
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  StaticHttpUserAgentSettings http_user_agent_settings(
      std::string() , kConfiguredUserAgent);
  session_context_.http_user_agent_settings = &http_user_agent_settings;
  CreateSession();
  request_.url = GURL("https://mail.example.org/");
  request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
                                   kRequestUserAgent);
  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_QUIC_PROTOCOL_ERROR, callback.WaitForResult());
  EXPECT_TRUE(mock_quic_data.AllReadDataConsumed());
  EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
}
TEST_P ( QuicNetworkTransactionTest , QuicProxyUserAgent ) { const char kConfiguredUserAgent [ ] = " " ; const char kRequestUserAgent [ ] = " " ; 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 ) ) ) ; } spdy :: SpdyHeaderBlock headers = ConnectRequestHeaders ( " " ) ; headers [ " " ] = kConfiguredUserAgent ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( packet_num ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , false , VersionUsesHttp3 ( version_ . transport_version ) ? MEDIUM : HttpProxyConnectJob :: kH2QuicTunnelPriority , std :: move ( headers ) , 0 ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_CONNECTION_FAILED ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; StaticHttpUserAgentSettings http_user_agent_settings ( std :: string ( ) , kConfiguredUserAgent ) ; session_context_ . http_user_agent_settings = & http_user_agent_settings ; CreateSession ( ) ; request_ . url = GURL ( " " ) ; request_ . extra_headers . SetHeader ( HttpRequestHeaders :: kUserAgent , kRequestUserAgent ) ; 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_QUIC_PROTOCOL_ERROR , callback . WaitForResult ( ) ) ; EXPECT_TRUE ( mock_quic_data . AllReadDataConsumed ( ) ) ; EXPECT_TRUE ( mock_quic_data . AllWriteDataConsumed ( ) ) ; }
Checks if a request's specified "user-agent" header shows up correctly in the
CONNECT request to a QUIC proxy.
Checks if a request ' s specified " user - agent " header shows up correctly in the CONNECT request to a QUIC proxy .
// Return an error, so the transaction stops here (this test isn't interested // in the rest). /* accept_language */