This commit is contained in:
Matt Hamilton 2022-11-02 21:04:08 -04:00 committed by GitHub
commit 5b7d16a3b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -348,8 +348,13 @@ func (ctx *Context) RespHeader() http.Header {
// SetServeHeaders sets necessary content serve headers
func (ctx *Context) SetServeHeaders(filename string) {
ctx.Resp.Header().Set("Content-Description", "File Transfer")
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+filename)
if strings.HasSuffix(filename, ".pdf") {
ctx.Resp.Header().Set("Content-Disposition", "inline; filename=\""+filename+"\"")
ctx.Resp.Header().Set("Content-Type", "application/pdf")
} else {
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"")
}
ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
ctx.Resp.Header().Set("Expires", "0")
ctx.Resp.Header().Set("Cache-Control", "must-revalidate")