aboutsummaryrefslogtreecommitdiffstats
path: root/routers/common
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-25 12:46:28 +0100
committerGitHub <noreply@github.com>2022-11-25 13:46:28 +0200
commitff4e292b3fe49ee3086f45de1717301981e5f5f2 (patch)
tree030cda05bc5d14f4e0c2a4f6cf046e5a0d890a8a /routers/common
parent9ba4ef93ff114588f2392ee130a19bdeae3c61da (diff)
downloadgitea-ff4e292b3fe49ee3086f45de1717301981e5f5f2.tar.gz
gitea-ff4e292b3fe49ee3086f45de1717301981e5f5f2.zip
Add support for HEAD requests in Maven registry (#21834) (#21929)
Backport of #21834 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/common')
-rw-r--r--routers/common/repo.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/routers/common/repo.go b/routers/common/repo.go
index f4b813d6b4..340eb1809f 100644
--- a/routers/common/repo.go
+++ b/routers/common/repo.go
@@ -5,7 +5,6 @@
package common
import (
- "fmt"
"io"
"path"
"path/filepath"
@@ -52,16 +51,16 @@ func ServeData(ctx *context.Context, filePath string, size int64, reader io.Read
buf = buf[:n]
}
+ opts := &context.ServeHeaderOptions{
+ Filename: path.Base(filePath),
+ }
+
if size >= 0 {
- ctx.Resp.Header().Set("Content-Length", fmt.Sprintf("%d", size))
+ opts.ContentLength = &size
} else {
log.Error("ServeData called to serve data: %s with size < 0: %d", filePath, size)
}
- opts := &context.ServeHeaderOptions{
- Filename: path.Base(filePath),
- }
-
sniffedType := typesniffer.DetectContentType(buf)
isPlain := sniffedType.IsText() || ctx.FormBool("render")