summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-08-13 18:18:18 +0100
committerGitHub <noreply@github.com>2020-08-13 18:18:18 +0100
commit2ef318e6f1d0c674e894d2d1f25ca79498663466 (patch)
tree4914d7c95e814af2ffdc8ea7101b6f1b86e03ae4 /modules
parente266ba30cca17bdb5c50fd0cd30d2e429e58ac26 (diff)
downloadgitea-2ef318e6f1d0c674e894d2d1f25ca79498663466.tar.gz
gitea-2ef318e6f1d0c674e894d2d1f25ca79498663466.zip
Add Access-Control-Expose-Headers (#12446)
Fix #12424 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/context/context.go1
-rw-r--r--modules/lfs/server.go2
2 files changed, 3 insertions, 0 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index b26528f6b2..cc68fb093b 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -222,6 +222,7 @@ func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interfa
ctx.Resp.Header().Set("Expires", "0")
ctx.Resp.Header().Set("Cache-Control", "must-revalidate")
ctx.Resp.Header().Set("Pragma", "public")
+ ctx.Resp.Header().Set("Access-Control-Expose-Headers", "Content-Disposition")
http.ServeContent(ctx.Resp, ctx.Req.Request, name, modtime, r)
}
diff --git a/modules/lfs/server.go b/modules/lfs/server.go
index c39bf40d69..f227ebe2eb 100644
--- a/modules/lfs/server.go
+++ b/modules/lfs/server.go
@@ -183,6 +183,7 @@ func getContentHandler(ctx *context.Context) {
}
ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, toByte, meta.Size-fromByte))
+ ctx.Resp.Header().Set("Access-Control-Expose-Headers", "Content-Range")
}
}
@@ -204,6 +205,7 @@ func getContentHandler(ctx *context.Context) {
decodedFilename, err := base64.RawURLEncoding.DecodeString(filename)
if err == nil {
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+string(decodedFilename)+"\"")
+ ctx.Resp.Header().Set("Access-Control-Expose-Headers", "Content-Disposition")
}
}