Send HTTP/3 GOAWAY for ImmediateGoAwaySession in tests.
Testing only. not protected.
PiperOrigin-RevId: 310955172
Change-Id: I4031680a40ebdf50a65e5faa6c34e6581343ec4a
diff --git a/quic/test_tools/quic_test_server.cc b/quic/test_tools/quic_test_server.cc
index 11be664..1b6452e 100644
--- a/quic/test_tools/quic_test_server.cc
+++ b/quic/test_tools/quic_test_server.cc
@@ -235,14 +235,27 @@
}
void ImmediateGoAwaySession::OnCryptoFrame(const QuicCryptoFrame& frame) {
- // In IETF QUIC, GOAWAY lives up in HTTP/3 layer. Even if it's a immediate
- // goaway session, goaway shouldn't be sent when crypto frame is received.
+ // In IETF QUIC, GOAWAY lives up in HTTP/3 layer. It's sent in a QUIC stream
+ // and requires encryption. Thus the sending is done in
+ // OnNewEncryptionKeyAvailable().
if (!VersionUsesHttp3(transport_version())) {
SendGoAway(QUIC_PEER_GOING_AWAY, "");
}
QuicSimpleServerSession::OnCryptoFrame(frame);
}
+void ImmediateGoAwaySession::OnNewEncryptionKeyAvailable(
+ EncryptionLevel level,
+ std::unique_ptr<QuicEncrypter> encrypter) {
+ QuicSimpleServerSession::OnNewEncryptionKeyAvailable(level,
+ std::move(encrypter));
+ if (VersionUsesHttp3(transport_version())) {
+ if (IsEncryptionEstablished() && !http3_goaway_sent()) {
+ SendHttp3GoAway();
+ }
+ }
+}
+
} // namespace test
} // namespace quic