diff --git a/tomee/apache-tomee/src/patch/java/org/apache/coyote/http2/Http2Parser.java b/tomee/apache-tomee/src/patch/java/org/apache/coyote/http2/Http2Parser.java index 72c30532e12..8588d15bb6f 100644 --- a/tomee/apache-tomee/src/patch/java/org/apache/coyote/http2/Http2Parser.java +++ b/tomee/apache-tomee/src/patch/java/org/apache/coyote/http2/Http2Parser.java @@ -289,6 +289,9 @@ protected void readHeadersFrame(int streamId, int flags, int payloadSize, ByteBu swallowPayload(streamId, FrameType.HEADERS.getId(), padLength, true, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (Flags.isEndOfHeaders(flags)) { onHeadersComplete(streamId); } else { @@ -467,6 +470,9 @@ protected void readContinuationFrame(int streamId, int flags, int payloadSize, B readHeaderPayload(streamId, payloadSize, buffer); + // Validate the headers so far + hpackDecoder.getHeaderEmitter().validateHeaders(); + if (endOfHeaders) { headersCurrentStream = -1; onHeadersComplete(streamId); @@ -633,11 +639,6 @@ protected void onHeadersComplete(int streamId) throws Http2Exception { 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);