Skip to content

Set Content-Length for tile responses (fixes chunked encoding for gzipped tiles) - #283

Merged
bdon merged 2 commits into
protomaps:mainfrom
HudHud-Maps:hud-3353/fix-content-length
Jul 22, 2026
Merged

bdon merged 2 commits into
protomaps:mainfrom
HudHud-Maps:hud-3353/fix-content-length

Conversation

@YazeedAlKhalaf

Copy link
Copy Markdown
Contributor

This PR sets the Content-Length header for tile responses. Normally ServeContent would set the Content-Length header, but a commit in the net/http package 3 years ago changed that for responses with Content-Encoding set.

But for pmtiles, the content is already gzipped, and we are just passing it, so not setting Content-Length doesn't make sense for us, especially that it breaks things like Cloudflare CDN which relies on Content-Length header being present to cache anything in its reserve.

Diff:
https://github.com/golang/go/blob/master/src/net/http/fs.go#L399-L426

@bdon
bdon merged commit a3e4951 into protomaps:main Jul 22, 2026
3 of 4 checks passed
@bdon

bdon commented Jul 22, 2026

Copy link
Copy Markdown
Member

Thanks for the enhancement and test case. I released version 1.31.2 with the change.

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.

2 participants