Expands Http2VisitorInterface::OnHeaderForStream() to return an enum representing either OK, invalid or RST_STREAM.
This turns out to be necessary for tests related to invalid headers to pass.
This change fills in the implementation gap in the OG stack, with one minor difference: since the application is indicating the header error and potentially queuing the RST_STREAM, CloseStream() does not re-deliver the same error code back to the application.
PiperOrigin-RevId: 381958205
diff --git a/http2/adapter/nghttp2_callbacks.cc b/http2/adapter/nghttp2_callbacks.cc
index 4ab163d..c2b64f4 100644
--- a/http2/adapter/nghttp2_callbacks.cc
+++ b/http2/adapter/nghttp2_callbacks.cc
@@ -161,9 +161,17 @@
void* user_data) {
QUICHE_CHECK_NE(user_data, nullptr);
auto* visitor = static_cast<Http2VisitorInterface*>(user_data);
- const bool success = visitor->OnHeaderForStream(
- frame->hd.stream_id, ToStringView(name), ToStringView(value));
- return success ? 0 : NGHTTP2_ERR_HTTP_HEADER;
+ const Http2VisitorInterface::OnHeaderResult result =
+ visitor->OnHeaderForStream(frame->hd.stream_id, ToStringView(name),
+ ToStringView(value));
+ switch (result) {
+ case Http2VisitorInterface::HEADER_OK:
+ return 0;
+ case Http2VisitorInterface::HEADER_CONNECTION_ERROR:
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ case Http2VisitorInterface::HEADER_RST_STREAM:
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
+ }
}
int OnBeforeFrameSent(nghttp2_session* /* session */,