]> source.dussan.org Git - gitea.git/commit
Rework raw file http header logic (#20484)
authorsilverwind <me@silverwind.io>
Fri, 29 Jul 2022 15:26:55 +0000 (17:26 +0200)
committerGitHub <noreply@github.com>
Fri, 29 Jul 2022 15:26:55 +0000 (17:26 +0200)
commiteaf653f843cb887bc2f4ff664010b4e969dd5446
treeb331347455827acc03aacb2e9f8aa110ab78ba0f
parent7fe77f0167b264c7a8bcfab05385594b6c8141c8
Rework raw file http header logic (#20484)

- Always respect the user's configured mime type map
- Allow more types like image/pdf/video/audio to serve with correct content-type
- Shorten cache duration of raw files to 5 minutes, matching GitHub
- Don't set `content-disposition: attachment`, let the browser decide whether it wants to download or display a file directly
- Implement rfc5987 for filenames, remove previous hack. Confirmed it working in Safari.
- Make PDF attachment work in Safari by removing `sandbox` attribute.

This change will make a lot more file types open directly in browser now. Logic should generally be more readable than before with less `if` nesting and such.

Replaces: https://github.com/go-gitea/gitea/pull/20460
Replaces: https://github.com/go-gitea/gitea/pull/20455
Fixes: https://github.com/go-gitea/gitea/issues/20404
modules/typesniffer/typesniffer.go
routers/common/repo.go