summaryrefslogtreecommitdiffstats
path: root/routers/common/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/common/repo.go')
-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")