This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8e03be9f2698f2da9027d40b9e9c0c9429b74dc0 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jan 25 12:13:55 2024 +0000 Report HTTP/2 header parsing errors earlier --- java/org/apache/coyote/http2/Http2Parser.java | 11 ++++++----- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2Parser.java b/java/org/apache/coyote/http2/Http2Parser.java index 5053a219be..c1f8542227 100644 --- a/java/org/apache/coyote/http2/Http2Parser.java +++ b/java/org/apache/coyote/http2/Http2Parser.java @@ -283,6 +283,9 @@ class Http2Parser { swallowPayload(streamId, FrameType.HEADERS.getId(), padLength, true, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (Flags.isEndOfHeaders(flags)) { onHeadersComplete(streamId); } else { @@ -446,6 +449,9 @@ class Http2Parser { readHeaderPayload(streamId, payloadSize, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (endOfHeaders) { headersCurrentStream = -1; onHeadersComplete(streamId); @@ -637,11 +643,6 @@ class Http2Parser { Http2Error.COMPRESSION_ERROR); } - // Delay validation (and triggering any exception) until this point - // since all the headers still have to be read if a StreamException is - // going to be thrown. - hpackDecoder.getHeaderEmitter().validateHeaders(); - synchronized (output) { output.headersEnd(streamId, headersEndStream); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0aa6868e70..f6cf372b9a 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -171,6 +171,11 @@ <code>Content-Type</code> value to improve performance by reducing repeated <code>byte[]</code> to <code>String</code> conversions. (markt) </fix> + <fix> + Improve error reporting to HTTP/2 clients for header processing errors + by reporting problems at the end of the frame where the error was + detected rather than at the end of the headers. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org