From cf825f16a889c3f9c128f5c1b46bda978c6f979d Mon Sep 17 00:00:00 2001 From: Shang Xiang Date: Tue, 26 Nov 2024 16:30:35 +0100 Subject: [PATCH] Update the pointer of Continuation's headerBuffer after copying the payload. --- .../core5/http2/impl/nio/AbstractH2StreamMultiplexer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java index f7792f8aa..c9d67c9e3 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java @@ -1342,8 +1342,11 @@ void copyPayload(final ByteBuffer payload) { if (payload == null) { return; } - headerBuffer.ensureCapacity(payload.remaining()); - payload.get(headerBuffer.array(), headerBuffer.length(), payload.remaining()); + int originalLength = headerBuffer.length(); + int toCopy = payload.remaining(); + headerBuffer.ensureCapacity(toCopy); + payload.get(headerBuffer.array(), originalLength, toCopy); + headerBuffer.setLength(originalLength + toCopy); } ByteBuffer getContent() {