gzip middleware keeps Content-Length: EXR preview fails with ERR_CONTENT_LENGTH_MISMATCH #25

Closed
opened 2026-10-23 13:29:17 +00:00 by jerry · 1 comment
Contributor

EXR Preview modal always shows "Failed to load preview image." Browser console: net::ERR_CONTENT_LENGTH_MISMATCH on /api/jobs/{id}/files/{fileId}/preview-exr.

Root cause: gzipMiddleware (internal/manager/manager.go ~L471) gzips the body but leaves the handler's Content-Length (uncompressed size). Proof on 0.0.11:

  • curl without Accept-Encoding: 200, full PNG, fine
  • curl -H Accept-Encoding:gzip: Content-Encoding gzip + Content-Length 6820608; curl --compressed exits 18 (partial transfer)

Fix: drop Content-Length in the gzip wrapper before WriteHeader, and skip gzip for already-compressed types (image/png, zip, file downloads). Likely affects every endpoint that sets Content-Length.

Done = preview loads in Chrome/Brave, curl --compressed exits 0, release cut. Filed by Jerry for Justin.

EXR Preview modal always shows "Failed to load preview image." Browser console: net::ERR_CONTENT_LENGTH_MISMATCH on /api/jobs/{id}/files/{fileId}/preview-exr. Root cause: gzipMiddleware (internal/manager/manager.go ~L471) gzips the body but leaves the handler's Content-Length (uncompressed size). Proof on 0.0.11: - curl without Accept-Encoding: 200, full PNG, fine - curl -H Accept-Encoding:gzip: Content-Encoding gzip + Content-Length 6820608; curl --compressed exits 18 (partial transfer) Fix: drop Content-Length in the gzip wrapper before WriteHeader, and skip gzip for already-compressed types (image/png, zip, file downloads). Likely affects every endpoint that sets Content-Length. Done = preview loads in Chrome/Brave, curl --compressed exits 0, release cut. Filed by Jerry for Justin.
Owner

Clear spec and repro, so this goes straight to implementation. Keep the fix in the gzip wrapper (drop Content-Length before WriteHeader, skip already-compressed types), add a test that a gzipped response decodes cleanly, leave the Go version alone, and don't merge yourself. A release cut follows the merge.

Clear spec and repro, so this goes straight to implementation. Keep the fix in the gzip wrapper (drop Content-Length before WriteHeader, skip already-compressed types), add a test that a gzipped response decodes cleanly, leave the Go version alone, and don't merge yourself. A release cut follows the merge.
linus closed this issue 2026-10-23 13:34:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
s1d3sw1ped/jiggablend#25
No description provided.