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:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2022-01-29 19:52:48 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-01-29 19:52:48 +0300
commit4f047b8fdfa87cc80b7f5d33c03c97206d855765 (patch)
tree44f0eed70b0396c439e8c4cb5b580cdbf0cdbb4b
parent008e2afc8d6de32a30696dbf813ebc0fdf5192c7 (diff)
fix: catch io.copy errors when serving content
-rw-r--r--internal/vfs/serving/serving.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/vfs/serving/serving.go b/internal/vfs/serving/serving.go
index 6f45e1d5..8f86d476 100644
--- a/internal/vfs/serving/serving.go
+++ b/internal/vfs/serving/serving.go
@@ -47,10 +47,16 @@ func serveContent(w http.ResponseWriter, r *http.Request, modtime time.Time, con
return
}
- w.WriteHeader(code)
+ if r.Method == http.MethodHead {
+ w.WriteHeader(code)
+ }
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)
+ }
}
}