Skip to content

Use HTTP dates in ReadOnlyHttp2Headers.containsTimeMillis - #18271

Merged
normanmaurer merged 2 commits into
netty:4.2from
wozhenbang2004:fix-readonly-http2-contains-time-millis
Nov 5, 2026
Merged

normanmaurer merged 2 commits into
netty:4.2from
wozhenbang2004:fix-readonly-http2-contains-time-millis

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Motivation:

ReadOnlyHttp2Headers.getTimeMillis reads HTTP dates, but containsTimeMillis searches for decimal epoch milliseconds. A valid HTTP-date header therefore cannot be found with the matching timestamp.

Modification:

Use CharSequenceValueConverter.convertTimeMillis, as writable headers do. Add a regression test covering a matching HTTP date, a different timestamp, and a raw decimal value.

Result:

Read-only and writable HTTP/2 headers use the same representation for time values. This changes the previous behavior for raw decimal millisecond headers: they no longer match containsTimeMillis; callers handling numeric headers should use containsLong.

Motivation:

ReadOnlyHttp2Headers.getTimeMillis reads HTTP dates, but containsTimeMillis searches for decimal epoch milliseconds.

Modification:

Use CharSequenceValueConverter.convertTimeMillis, as writable headers do.

Result:

Read-only and writable HTTP/2 headers use the same representation for time values. Raw decimal millisecond headers no longer match containsTimeMillis; callers handling numeric headers should use containsLong.
Cover matching HTTP dates, different timestamps, and decimal millisecond values that should use containsLong.
@testlens-app

testlens-app Bot commented Nov 5, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: e6701c6
▶️ Tests: 56593 executed
⚪️ Checks: 26/26 completed


Learn more about TestLens at testlens.app/docs.

@normanmaurer

Copy link
Copy Markdown
Member

@wozhenbang2004

Copy link
Copy Markdown
Contributor Author

Thanks @normanmaurer, I've submitted the ICLA.

@normanmaurer
normanmaurer merged commit 7599557 into netty:4.2 Nov 5, 2026
27 checks passed
@normanmaurer normanmaurer added this to the 4.2.21.Final milestone Nov 5, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 5, 2026
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #18286

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 5, 2026
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #18287

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Nov 5, 2026
chrisvest pushed a commit that referenced this pull request Nov 5, 2026
…lis (#18286)

Auto-port of #18271 to 5.0
Cherry-picked commit: 7599557

---
Motivation:

`ReadOnlyHttp2Headers.getTimeMillis` reads HTTP dates, but
`containsTimeMillis` searches for decimal epoch milliseconds. A valid
HTTP-date header therefore cannot be found with the matching timestamp.

Modification:

Use `CharSequenceValueConverter.convertTimeMillis`, as writable headers
do. Add a regression test covering a matching HTTP date, a different
timestamp, and a raw decimal value.

Result:

Read-only and writable HTTP/2 headers use the same representation for
time values. This changes the previous behavior for raw decimal
millisecond headers: they no longer match `containsTimeMillis`; callers
handling numeric headers should use `containsLong`.

Co-authored-by: Kayokoi <[email protected]>
chrisvest pushed a commit that referenced this pull request Nov 6, 2026
…lis (#18287)

Auto-port of #18271 to 4.1
Cherry-picked commit: 7599557

---
Motivation:

`ReadOnlyHttp2Headers.getTimeMillis` reads HTTP dates, but
`containsTimeMillis` searches for decimal epoch milliseconds. A valid
HTTP-date header therefore cannot be found with the matching timestamp.

Modification:

Use `CharSequenceValueConverter.convertTimeMillis`, as writable headers
do. Add a regression test covering a matching HTTP date, a different
timestamp, and a raw decimal value.

Result:

Read-only and writable HTTP/2 headers use the same representation for
time values. This changes the previous behavior for raw decimal
millisecond headers: they no longer match `containsTimeMillis`; callers
handling numeric headers should use `containsLong`.

Co-authored-by: Kayokoi <[email protected]>
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.

3 participants