src/net/quic/quic_network_transaction_unittest.cc
// crbug.com/705109 - this confirms that matching request with a body
// triggers a crash (pre-fix).
crbug.com/705109 - this confirms that matching request with a body
triggers a crash (pre-fix).
crbug . com / 705109 - this confirms that matching request with a body triggers a crash ( pre - fix ) .
TEST_P(QuicNetworkTransactionTest, QuicServerPushMatchesRequestWithBody) {
  client_maker_->set_max_allowed_push_id(quic::kMaxQuicStreamId);
  context_.params()->max_allowed_push_id = quic::kMaxQuicStreamId;
  context_.params()->origins_to_force_quic_on.insert(
      HostPortPair::FromString("mail.example.org:443"));
  MockQuicData mock_quic_data(version_);
  uint64_t client_packet_number = 1;
  if (VersionUsesHttp3(version_.transport_version)) {
    mock_quic_data.AddWrite(
        SYNCHRONOUS, ConstructInitialSettingsPacket(client_packet_number++));
  }
  mock_quic_data.AddWrite(
      SYNCHRONOUS,
      ConstructClientRequestHeadersPacket(
          client_packet_number++, GetNthClientInitiatedBidirectionalStreamId(0),
          true, true, GetRequestHeaders("GET", "https", "/")));
  mock_quic_data.AddRead(
      ASYNC,
      ConstructServerPushPromisePacket(
          1, GetNthClientInitiatedBidirectionalStreamId(0),
          GetNthServerInitiatedUnidirectionalStreamId(0), false,
          GetRequestHeaders("GET", "https", "/pushed.jpg"), &server_maker_));
  if ((client_headers_include_h2_stream_dependency_ &&
       version_.transport_version >= quic::QUIC_VERSION_43 &&
       !VersionUsesHttp3(version_.transport_version))) {
    mock_quic_data.AddWrite(
        SYNCHRONOUS,
        ConstructClientPriorityPacket(
            client_packet_number++, false,
            GetNthServerInitiatedUnidirectionalStreamId(0),
            GetNthClientInitiatedBidirectionalStreamId(0), DEFAULT_PRIORITY));
  }
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 2, GetNthClientInitiatedBidirectionalStreamId(0), false, false,
                 GetResponseHeaders("200 OK")));
  mock_quic_data.AddWrite(
      SYNCHRONOUS, ConstructClientAckPacket(client_packet_number++, 2, 1, 1));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 3, GetNthServerInitiatedUnidirectionalStreamId(0), false,
                 false, GetResponseHeaders("200 OK")));
  std::string header = ConstructDataHeader(6);
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 4, GetNthClientInitiatedBidirectionalStreamId(0), false, true,
                 header + "hello!"));
  mock_quic_data.AddWrite(
      SYNCHRONOUS, ConstructClientAckPacket(client_packet_number++, 4, 3, 1));
  std::string header2 = ConstructDataHeader(10);
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 5, GetNthServerInitiatedUnidirectionalStreamId(0), false, true,
                 header2 + "and hello!"));
  mock_quic_data.AddWrite(SYNCHRONOUS,
                          ConstructClientAckAndRstPacket(
                              client_packet_number++,
                              GetNthServerInitiatedUnidirectionalStreamId(0),
                              quic::QUIC_STREAM_CANCELLED, 5, 5, 1));
  const char kBody[] = "1";
  std::string header3 = ConstructDataHeader(1);
  if (!version_.HasIetfQuicFrames()) {
    mock_quic_data.AddWrite(
        SYNCHRONOUS,
        ConstructClientRequestHeadersAndDataFramesPacket(
            client_packet_number++,
            GetNthClientInitiatedBidirectionalStreamId(1), false, true,
            DEFAULT_PRIORITY, GetRequestHeaders("GET", "https", "/pushed.jpg"),
            GetNthServerInitiatedUnidirectionalStreamId(0), nullptr, {kBody}));
  } else {
    mock_quic_data.AddWrite(
        SYNCHRONOUS,
        ConstructClientRequestHeadersAndDataFramesPacket(
            client_packet_number++,
            GetNthClientInitiatedBidirectionalStreamId(1), false, true,
            DEFAULT_PRIORITY, GetRequestHeaders("GET", "https", "/pushed.jpg"),
            GetNthServerInitiatedUnidirectionalStreamId(0), nullptr,
            {header3, kBody}));
  }
  mock_quic_data.AddRead(
      ASYNC, ConstructServerResponseHeadersPacket(
                 6, GetNthClientInitiatedBidirectionalStreamId(1), false, false,
                 GetResponseHeaders("200 OK")));
  mock_quic_data.AddRead(
      ASYNC, ConstructServerDataPacket(
                 7, GetNthClientInitiatedBidirectionalStreamId(1), false, true,
                 header2 + "and hello!"));
  mock_quic_data.AddWrite(
      SYNCHRONOUS, ConstructClientAckPacket(client_packet_number++, 7, 6, 1));
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);  
  mock_quic_data.AddRead(ASYNC, 0);               
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  AddHangingNonAlternateProtocolSocketData();
  CreateSession();
  SendRequestAndExpectQuicResponse("hello!");
  request_.url = GURL("https://mail.example.org/pushed.jpg");
  ChunkedUploadDataStream upload_data(0);
  upload_data.AppendData("1", 1, true);
  request_.upload_data_stream = &upload_data;
  SendRequestAndExpectQuicResponse("and hello!");
}
TEST_P ( QuicNetworkTransactionTest , QuicServerPushMatchesRequestWithBody ) { client_maker_ -> set_max_allowed_push_id ( quic :: kMaxQuicStreamId ) ; context_ . params ( ) -> max_allowed_push_id = quic :: kMaxQuicStreamId ; context_ . params ( ) -> origins_to_force_quic_on . insert ( HostPortPair :: FromString ( " " ) ) ; MockQuicData mock_quic_data ( version_ ) ; uint64_t client_packet_number = 1 ; if ( VersionUsesHttp3 ( version_ . transport_version ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructInitialSettingsPacket ( client_packet_number ++ ) ) ; } mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersPacket ( client_packet_number ++ , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , true , true , GetRequestHeaders ( " " , " " , " " ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerPushPromisePacket ( 1 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , false , GetRequestHeaders ( " " , " " , " " ) , & server_maker_ ) ) ; if ( ( client_headers_include_h2_stream_dependency_ && version_ . transport_version >= quic :: QUIC_VERSION_43 && ! VersionUsesHttp3 ( version_ . transport_version ) ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientPriorityPacket ( client_packet_number ++ , false , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , DEFAULT_PRIORITY ) ) ; } mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 2 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , false , GetResponseHeaders ( " " ) ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( client_packet_number ++ , 2 , 1 , 1 ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 3 , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , false , false , GetResponseHeaders ( " " ) ) ) ; std :: string header = ConstructDataHeader ( 6 ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 4 , GetNthClientInitiatedBidirectionalStreamId ( 0 ) , false , true , header + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( client_packet_number ++ , 4 , 3 , 1 ) ) ; std :: string header2 = ConstructDataHeader ( 10 ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 5 , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , false , true , header2 + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckAndRstPacket ( client_packet_number ++ , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , quic :: QUIC_STREAM_CANCELLED , 5 , 5 , 1 ) ) ; const char kBody [ ] = " " ; std :: string header3 = ConstructDataHeader ( 1 ) ; if ( ! version_ . HasIetfQuicFrames ( ) ) { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersAndDataFramesPacket ( client_packet_number ++ , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , true , DEFAULT_PRIORITY , GetRequestHeaders ( " " , " " , " " ) , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , nullptr , { kBody } ) ) ; } else { mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientRequestHeadersAndDataFramesPacket ( client_packet_number ++ , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , true , DEFAULT_PRIORITY , GetRequestHeaders ( " " , " " , " " ) , GetNthServerInitiatedUnidirectionalStreamId ( 0 ) , nullptr , { header3 , kBody } ) ) ; } mock_quic_data . AddRead ( ASYNC , ConstructServerResponseHeadersPacket ( 6 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , false , GetResponseHeaders ( " " ) ) ) ; mock_quic_data . AddRead ( ASYNC , ConstructServerDataPacket ( 7 , GetNthClientInitiatedBidirectionalStreamId ( 1 ) , false , true , header2 + " " ) ) ; mock_quic_data . AddWrite ( SYNCHRONOUS , ConstructClientAckPacket ( client_packet_number ++ , 7 , 6 , 1 ) ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; AddHangingNonAlternateProtocolSocketData ( ) ; CreateSession ( ) ; SendRequestAndExpectQuicResponse ( " " ) ; request_ . url = GURL ( " " ) ; ChunkedUploadDataStream upload_data ( 0 ) ; upload_data . AppendData ( " " , 1 , true ) ; request_ . upload_data_stream = & upload_data ; SendRequestAndExpectQuicResponse ( " " ) ; }
crbug.com/705109 - this confirms that matching request with a body
triggers a crash (pre-fix).
crbug . com / 705109 - this confirms that matching request with a body triggers a crash ( pre - fix ) .
// Because the matching request has a body, we will see the push // stream get cancelled, and the matching request go out on the // wire. // We see the same response as for the earlier pushed and cancelled // stream. // No more data to read // EOF // The non-alternate protocol job needs to hang in order to guarantee that // the alternate-protocol job will "win". // PUSH_PROMISE handling in the http layer gets exercised here.