src/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc
// Tests that closing a open outgoing stream can trigger a promised resource in
// the queue to be send out.
Tests that closing a open outgoing stream can trigger a promised resource in
the queue to be send out.
Tests that closing a open outgoing stream can trigger a promised resource in the queue to be send out .
TEST_P(QuicSimpleServerSessionServerPushTest,
       CloseStreamToHandleMorePromisedStream) {
  MaybeConsumeHeadersStreamData();
  if (VersionUsesHttp3(transport_version())) {
    session_->EnableServerPush();
    session_->OnMaxPushIdFrame(kMaxQuicStreamId);
  }
  size_t num_resources = kMaxStreamsForTest + 1;
  if (VersionHasIetfQuicFrames(transport_version())) {
    EXPECT_CALL(*connection_, SendControlFrame(_))
        .WillOnce(Invoke(&ClearControlFrame));
  }
  QuicByteCount data_frame_header_length = PromisePushResources(num_resources);
  QuicStreamId stream_to_open;
  if (VersionUsesHttp3(transport_version())) {
    stream_to_open =
        GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 3);
  } else {
    stream_to_open = GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest);
  }
  QuicStreamId stream_got_reset = GetNthServerInitiatedUnidirectionalId(3);
  EXPECT_CALL(*connection_, SendControlFrame(_));
  if (!VersionHasIetfQuicFrames(transport_version())) {
    EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
    EXPECT_CALL(*connection_,
                OnStreamReset(stream_got_reset, QUIC_RST_ACKNOWLEDGEMENT));
  }
  QuicStreamOffset offset = 0;
  if (VersionUsesHttp3(transport_version())) {
    EXPECT_CALL(*connection_,
                SendStreamData(stream_to_open, 1, offset, NO_FIN));
    offset++;
    EXPECT_CALL(*connection_,
                SendStreamData(stream_to_open, kHeadersFrameHeaderLength,
                               offset, NO_FIN));
    offset += kHeadersFrameHeaderLength;
    EXPECT_CALL(*connection_,
                SendStreamData(stream_to_open, kHeadersFramePayloadLength,
                               offset, NO_FIN));
    offset += kHeadersFramePayloadLength;
    EXPECT_CALL(*connection_,
                SendStreamData(stream_to_open, data_frame_header_length, offset,
                               NO_FIN));
    offset += data_frame_header_length;
  }
  EXPECT_CALL(*connection_, SendStreamData(stream_to_open, _, offset, NO_FIN))
      .WillOnce(Return(
          QuicConsumedData(kStreamFlowControlWindowSize - offset, false)));
  EXPECT_CALL(*session_, SendBlocked(stream_to_open));
  QuicRstStreamFrame rst(kInvalidControlFrameId, stream_got_reset,
                         QUIC_STREAM_CANCELLED, 0);
  if (VersionHasIetfQuicFrames(transport_version())) {
    session_->OnMaxStreamsFrame(
        QuicMaxStreamsFrame(0, num_resources + 3, true));
  } else {
    session_->OnRstStream(rst);
  }
  InjectStopSending(stream_got_reset, QUIC_STREAM_CANCELLED);
}
TEST_P ( QuicSimpleServerSessionServerPushTest , CloseStreamToHandleMorePromisedStream ) { MaybeConsumeHeadersStreamData ( ) ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { session_ -> EnableServerPush ( ) ; session_ -> OnMaxPushIdFrame ( kMaxQuicStreamId ) ; } size_t num_resources = kMaxStreamsForTest + 1 ; if ( VersionHasIetfQuicFrames ( transport_version ( ) ) ) { EXPECT_CALL ( * connection_ , SendControlFrame ( _ ) ) . WillOnce ( Invoke ( & ClearControlFrame ) ) ; } QuicByteCount data_frame_header_length = PromisePushResources ( num_resources ) ; QuicStreamId stream_to_open ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { stream_to_open = GetNthServerInitiatedUnidirectionalId ( kMaxStreamsForTest + 3 ) ; } else { stream_to_open = GetNthServerInitiatedUnidirectionalId ( kMaxStreamsForTest ) ; } QuicStreamId stream_got_reset = GetNthServerInitiatedUnidirectionalId ( 3 ) ; EXPECT_CALL ( * connection_ , SendControlFrame ( _ ) ) ; if ( ! VersionHasIetfQuicFrames ( transport_version ( ) ) ) { EXPECT_CALL ( owner_ , OnRstStreamReceived ( _ ) ) . Times ( 1 ) ; EXPECT_CALL ( * connection_ , OnStreamReset ( stream_got_reset , QUIC_RST_ACKNOWLEDGEMENT ) ) ; } QuicStreamOffset offset = 0 ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { EXPECT_CALL ( * connection_ , SendStreamData ( stream_to_open , 1 , offset , NO_FIN ) ) ; offset ++ ; EXPECT_CALL ( * connection_ , SendStreamData ( stream_to_open , kHeadersFrameHeaderLength , offset , NO_FIN ) ) ; offset += kHeadersFrameHeaderLength ; EXPECT_CALL ( * connection_ , SendStreamData ( stream_to_open , kHeadersFramePayloadLength , offset , NO_FIN ) ) ; offset += kHeadersFramePayloadLength ; EXPECT_CALL ( * connection_ , SendStreamData ( stream_to_open , data_frame_header_length , offset , NO_FIN ) ) ; offset += data_frame_header_length ; } EXPECT_CALL ( * connection_ , SendStreamData ( stream_to_open , _ , offset , NO_FIN ) ) . WillOnce ( Return ( QuicConsumedData ( kStreamFlowControlWindowSize - offset , false ) ) ) ; EXPECT_CALL ( * session_ , SendBlocked ( stream_to_open ) ) ; QuicRstStreamFrame rst ( kInvalidControlFrameId , stream_got_reset , QUIC_STREAM_CANCELLED , 0 ) ; if ( VersionHasIetfQuicFrames ( transport_version ( ) ) ) { session_ -> OnMaxStreamsFrame ( QuicMaxStreamsFrame ( 0 , num_resources + 3 , true ) ) ; } else { session_ -> OnRstStream ( rst ) ; } InjectStopSending ( stream_got_reset , QUIC_STREAM_CANCELLED ) ; }
Tests that closing a open outgoing stream can trigger a promised resource in
the queue to be send out.
Tests that closing a open outgoing stream can trigger a promised resource in the queue to be send out .
// V99 will send out a stream-id-blocked frame when the we desired to exceed // the limit. This will clear the frames so that they do not block the later // rst-stream frame. // Resetting an open stream will close the stream and give space for extra // stream to be opened. // For version 99, this is covered in InjectStopSending() // The PromisePushedResources call, above, will have used all available // stream ids.  For version 99, stream ids are not made available until // a MAX_STREAMS frame is received. This emulates the reception of one. // For pre-v-99, the node monitors its own stream usage and makes streams // available as it closes/etc them. /*unidirectional=*/ // Create and inject a STOP_SENDING frame. In GOOGLE QUIC, receiving a // RST_STREAM frame causes a two-way close. For IETF QUIC, RST_STREAM causes // a one-way close.