Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2020-08-04 12:14:21 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2020-08-04 12:14:21 +0300
commitb2922c74ae775f4a56c784572c6672fa2c7332fa (patch)
tree3253f9544885b5898a6a6a46ce81fed7c5e88fb1 /internal/serving
parent84c3866ba69e2ca0ca7d512b09ae66458f5c1c5c (diff)
parent145ca20da54c333d32a37262f3dc687b62c8bd95 (diff)
Merge branch '315-gzip-content-length' into 'master'
Set Content-Length when Content-Encoding is set Closes #315 See merge request gitlab-org/gitlab-pages!227
Diffstat (limited to 'internal/serving')
-rw-r--r--internal/serving/disk/helpers.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/serving/disk/helpers.go b/internal/serving/disk/helpers.go
index 01f59767..271b63cc 100644
--- a/internal/serving/disk/helpers.go
+++ b/internal/serving/disk/helpers.go
@@ -6,6 +6,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "strconv"
"strings"
"golang.org/x/sys/unix"
@@ -68,11 +69,15 @@ func handleGZip(w http.ResponseWriter, r *http.Request, fullPath string) string
gzipPath := fullPath + ".gz"
// Ensure the .gz file is not a symlink
- if fi, err := os.Lstat(gzipPath); err != nil || !fi.Mode().IsRegular() {
+ fi, err := os.Lstat(gzipPath)
+ if err != nil || !fi.Mode().IsRegular() {
return fullPath
}
w.Header().Set("Content-Encoding", "gzip")
+ // http.ServeContent doesn't set Content-Length if Content-Encoding is set
+ w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10))
+
return gzipPath
}