Skip to content

fix(middleware): parse Accept-Encoding values exactly#1104

Open
JinRudy wants to merge 1 commit into
go-chi:masterfrom
JinRudy:fix/compress-accept-encoding-q0
Open

fix(middleware): parse Accept-Encoding values exactly#1104
JinRudy wants to merge 1 commit into
go-chi:masterfrom
JinRudy:fix/compress-accept-encoding-q0

Conversation

@JinRudy

@JinRudy JinRudy commented May 26, 2026

Copy link
Copy Markdown

Closes #1069

Summary

  • Match Accept-Encoding tokens exactly instead of using substring matching.
  • Treat an exact encoding with q=0 as not acceptable.
  • Add regression coverage for exact matches, quality values, and substring false positives.

Testing

  • go test ./middleware -run TestMatchAcceptEncoding -count=1
  • go test ./middleware
  • go test ./...
  • HTTPS_PROXY=http://127.0.0.1:7897 HTTP_PROXY=http://127.0.0.1:7897 ALL_PROXY=http://127.0.0.1:7897 go run golang.org/x/tools/cmd/goimports@latest -w middleware/compress.go middleware/compress_test.go
  • make test

- 精确匹配 Accept-Encoding 中的编码名称
- 拒绝 q=0 的压缩编码
- 添加编码匹配回归测试
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.

Compress middleware: matchAcceptEncoding uses substring match and ignores q=0

1 participant