Skip to content

test: preserve HTTP/1.1 response trailers across input segments - #1644

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/http1-response-trailer-final-empty-line
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/http1-response-trailer-final-empty-line

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Motivation

Existing parser tests deliver the trailer section and its terminating
empty line together. The parser must also retain a declared trailer
when that final empty line arrives in a separate input element.

Modification

Feed a valid, handwritten chunked HTTP/1.1 200 response with one declared trailer and no data chunks into the response parser. Supply the final CRLF in a separate input element, then check the status, declaration, exact terminal chunk and message completion.

Result

Cover trailer retention and completion across a legitimate parser input
boundary. No runtime code or socket behavior changes.

Tests

On JDK 17, the focused CRLF case passed on Scala 2.13.18 and 3.3.9 (1/1 each).
Scoped formatting, repository license headers, and whitespace checks
passed. No full CI run.

References

https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1.2
https://www.rfc-editor.org/rfc/rfc9110.html#section-6.6.2
https://github.com/netty/netty/blob/fd00bc3a2a02a614fca8241d16570801a3a08314/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java#L1338-L1365

@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 00:44

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits: the input is built with the response renderer, which always emits CRLF, so ResponseParserLFSpec runs identical CRLF input and the LF variant adds nothing. A hand-written input with generalRawMultiParseTo like the neighbouring tests would exercise LF and drop the renderer imports. Also, on an incomplete trailer the parser re-parses the whole last chunk, so retention holds fairly trivially.

@He-Pin
He-Pin force-pushed the test/http1-response-trailer-final-empty-line branch from ffc6bf2 to 222403f Compare November 26, 2026 12:59
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 13:01

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the hand-written input is clearer. One thing left: the test is now wrapped in if (mode == "CRLF") and builds its input with crlf(...), so it does not run in ResponseParserLFSpec at all. Could it use prep/newLine like the neighbouring tests so that it runs in both modes? If it fails with LF line endings, that would be worth knowing about.

Motivation: A valid chunked response must preserve declared trailers when the final line arrives separately.

Modification: Run the existing focused test in both header-line modes. Use the suite separator for the response head and keep standard CRLF for the chunked framing.

Result: Both parser suites verify the final trailer and message completion. No runtime change.

Tests: ResponseParserCRLFSpec and ResponseParserLFSpec, one focused case each on Scala 2.13.18 and 3.3.9 with JDK 17; scoped Scalafmt and git diff --check.

References: Apache Pekko HTTP apache#1644; RFC 9112 sections 2.2 and 7.1.
@He-Pin
He-Pin force-pushed the test/http1-response-trailer-final-empty-line branch from 222403f to 3fd9fb9 Compare November 26, 2026 18:52
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants