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:
authorJaime Martinez <jmartinez@gitlab.com>2022-01-31 02:16:25 +0300
committerJaime Martinez <jmartinez@gitlab.com>2022-01-31 02:16:25 +0300
commit682a80ca535e01d6c6e22540b9f15afe5f774016 (patch)
treef62aa330835bc20e6474d0505efa49ec8aef9255 /internal
parent41802815aa64a38e0db8957e43857a3b75f1517f (diff)
parent60f5b3459ee09c1439f1ee31938e6ee4b88f5ec5 (diff)
Merge branch 'fix/catch-serve-errors' into 'master'
fix: catch io.copy errors when serving content See merge request gitlab-org/gitlab-pages!676
Diffstat (limited to 'internal')
-rw-r--r--internal/vfs/serving/serving.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/vfs/serving/serving.go b/internal/vfs/serving/serving.go
index 6f45e1d5..57b0228f 100644
--- a/internal/vfs/serving/serving.go
+++ b/internal/vfs/serving/serving.go
@@ -47,10 +47,17 @@ func serveContent(w http.ResponseWriter, r *http.Request, modtime time.Time, con
return
}
- w.WriteHeader(code)
+ if r.Method == http.MethodHead {
+ w.WriteHeader(code)
+ return
+ }
if r.Method != http.MethodHead {
- io.Copy(w, content)
+ if _, err := io.Copy(w, content); err != nil {
+ errortracking.Capture(err, errortracking.WithRequest(r), errortracking.WithStackTrace())
+ logging.LogRequest(r).WithError(err).Error("error serving content")
+ httperrors.Serve500(w)
+ }
}
}