Remove static stream checks in QuicSession::OnRstStream() and let static sub-streams handle it.

The advantage of having sub stream classes override rather than QuicStream base class sanity check is that HTTP/3 streams are now able to throw HTTP/3 specific errors.

gfe-relnote: no behavior change. not protected.
PiperOrigin-RevId: 299190484
Change-Id: Icaa957f91eba4acb3518515b75d205bc22001ddc
diff --git a/quic/core/http/quic_headers_stream.cc b/quic/core/http/quic_headers_stream.cc
index 1e7feb3..8157dae 100644
--- a/quic/core/http/quic_headers_stream.cc
+++ b/quic/core/http/quic_headers_stream.cc
@@ -155,4 +155,9 @@
   }
 }
 
+void QuicHeadersStream::OnStreamReset(const QuicRstStreamFrame& /*frame*/) {
+  stream_delegate()->OnStreamError(QUIC_INVALID_STREAM_ID,
+                                   "Attempt to reset headers stream");
+}
+
 }  // namespace quic
diff --git a/quic/core/http/quic_headers_stream.h b/quic/core/http/quic_headers_stream.h
index e97a78d..3786ddf 100644
--- a/quic/core/http/quic_headers_stream.h
+++ b/quic/core/http/quic_headers_stream.h
@@ -50,6 +50,8 @@
                                   QuicByteCount data_length,
                                   bool fin_retransmitted) override;
 
+  void OnStreamReset(const QuicRstStreamFrame& frame) override;
+
  private:
   friend class test::QuicHeadersStreamPeer;
 
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 2e46a5c..bd62260 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -1171,6 +1171,7 @@
 
 TEST_P(QuicSpdySessionTestServer, OnRstStreamStaticStreamId) {
   QuicStreamId id;
+  std::string error_message;
   // Initialize HTTP/3 control stream.
   if (VersionUsesHttp3(transport_version())) {
     id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3);
@@ -1178,17 +1179,19 @@
 
     QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1));
     session_.OnStreamFrame(data1);
+    error_message = "Attempt to reset receive control stream";
   } else {
     id = QuicUtils::GetHeadersStreamId(transport_version());
+    error_message = "Attempt to reset headers stream";
   }
 
   // Send two bytes of payload.
   QuicRstStreamFrame rst1(kInvalidControlFrameId, id,
                           QUIC_ERROR_PROCESSING_STREAM, 0);
-  EXPECT_CALL(*connection_,
-              CloseConnection(
-                  QUIC_INVALID_STREAM_ID, "Attempt to reset a static stream",
-                  ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET));
+  EXPECT_CALL(
+      *connection_,
+      CloseConnection(QUIC_INVALID_STREAM_ID, error_message,
+                      ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET));
   session_.OnRstStream(rst1);
 }