Skip to content

fix(net): preserve byte ranges in gzip-wrapped file responses - #5612

Open
shizukunacho wants to merge 1 commit into
fatedier:devfrom
shizukunacho:fix/gzip-range-responses
Open

shizukunacho wants to merge 1 commit into
fatedier:devfrom
shizukunacho:fix/gzip-range-responses

Conversation

@shizukunacho

Copy link
Copy Markdown

WHY

HTTPGzipWrapper compresses http.FileServer responses even when the request contains Range. The file server has already calculated Content-Range and Content-Length for the requested file bytes, so compressing the body makes those headers incorrect. This affects the static_file plugin, which uses this wrapper.

With a 16-byte file (0123456789abcdef), Accept-Encoding: gzip and Range: bytes=0-9, the current code returns only the 10-byte gzip header instead of the requested bytes. A multipart range request also fails with unexpected EOF.

Pass requests with a Range header directly to the underlying handler, preserving its byte ranges and length. Full-file requests still support gzip. The regression test uses a real HTTP server and checks single-range and multipart contents, plus compressed and uncompressed full responses. Both range cases fail before the change and pass afterward.

Validation on Windows/amd64 with Go 1.26.11:

  • go test ./pkg/util/net ./pkg/plugin/client -count=1
  • go vet ./pkg/util/net ./pkg/plugin/client
  • gofmt and git diff --check

The full end-to-end suite was not run locally.

@kilo-code-bot

kilo-code-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • pkg/util/net/http.go
  • pkg/util/net/http_test.go

Validation: Static review only. Tests were not run under the read-only review restrictions.


Reviewed by gpt-6.1-sol · Input: 33 · Output: 2.7K · Cached: 268.9K

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.

1 participant