Skip to content

fix: match complete Accept-Encoding tokens - #2479

Merged
erikdubbelboer merged 3 commits into
valyala:masterfrom
jabrailkhalil:fix/accept-encoding-token-matching
Oct 17, 2026
Merged

erikdubbelboer merged 3 commits into
valyala:masterfrom
jabrailkhalil:fix/accept-encoding-token-matching

Conversation

@jabrailkhalil

@jabrailkhalil jabrailkhalil commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

HasAcceptEncoding and HasAcceptEncodingBytes now scan complete comma-separated tokens, trim optional whitespace, and compare token letters without case sensitivity. Prefix/suffix substrings still do not match; this does not add quality-value or wildcard negotiation.

The shared comparator uses the existing ASCII lowercase table, preserving punctuation instead of folding every byte with | 0x20. In particular, custom encodings containing ^ and ~ remain distinct. Regression cases cover both public APIs, positive mixed-case custom encodings, all 65,536 byte pairs, and compression through a real request/response round-trip.

Validation

  • Author validation at source 4ebca700c80b684cf8db9e2335fa24639ad5565b: complete shuffled tests and complete race tests pass on Linux, macOS and Windows with Go 1.26 and 1.27. Repository golangci-lint v2.14.0 passes. All nine jobs are successful; the validation-only workflow is outside this PR.
  • Restoring the reviewed comparator while retaining the tests makes both public APIs fail for ^/~ in both directions. The original pre-feature base also fails the token/compression regressions.
  • Local Windows focused tests pass over 20 shuffled repetitions, go vet ./... passes, and all five token benchmarks retain zero allocations. The complete local run fails only the unchanged direct-dial expectation in TestDialerGetDialFuncForTLSNoProxy; the same case fails three times on the unmodified base. I have not changed or skipped it.

Comment thread header.go Resolved
@erikdubbelboer erikdubbelboer added the needschange Changes are needed before this can be completed label Oct 13, 2026
@erikdubbelboer
erikdubbelboer merged commit 89a91a8 into valyala:master Oct 17, 2026
8 checks passed
@erikdubbelboer

Copy link
Copy Markdown
Collaborator

Thanks!

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for catching the punctuation case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needschange Changes are needed before this can be completed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants