Skip to content

test: cover a route-local gzip minimum on entity length - #1653

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/route-gzip-original-entity-length
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:test/route-gzip-original-entity-length

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 26, 2026

Copy link
Copy Markdown
Member

Motivation

A route-local Gzip filter can set a minimum response size. The decision needs the length of the original HTTP response entity, before encoding changes the entity and its length metadata.

Modification

Test a Gzip filter with a 1024-byte minimum on two ordinary typed responses. Verify that the 1023-byte response remains unchanged, while the 1024-byte response is labeled as Gzip and decompresses to the exact original bytes. No production code or default behavior changes.

Result

Covers the inclusive size boundary on the original entity for an opt-in, route-local filter.

Tests

  • JDK 17: the focused test passed on Scala 2.13.18 and Scala 3.3.9 (1/1 on each).
  • Scoped formatting and license-header checks, plus git diff --check, passed.

References

RFC 9110 §12.5.3.

Motivation:
The existing Gzip directive tests do not exercise the exact minimum
length of an application-provided response encoding filter.

Modification:
Use the public route-local Gzip filter on two known-length responses.
Verify the response below the limit is unchanged and the one at the
limit is compressed and decodes to its original bytes.

Result:
Protect the filter's access to the original entity length without
changing production code or the default encoding policy.

Tests:
Focused JDK 17 native tests passed on Scala 2.13.18 and 3.3.9.

References:
RFC 9110 section 12.5.3 for Accept-Encoding negotiation.
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 08:47

@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.

Question: the 1023/1024 boundary comes from the test's own lambda (contentLengthOption.exists(_ >= threshold)), so it's testing the test, and "original entity length, before encoding" can't fail since messageFilter always sees the unencoded message. What remains ("a custom messageFilter is honoured") is already covered by EncoderSpec and FlowCoderSpec. Maybe close, or turn it into a docs example?

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