func handleContentCopy()

in internal/vfs/serving/serving.go [63:78]


func handleContentCopy(w http.ResponseWriter, r *http.Request, content vfs.File) {
	defer slowlogs.Recorder(r.Context(), "serving.handleContentCopy")()
	if _, err := io.Copy(w, content); err != nil {
		if errors.Is(err, &vfs.ReadError{}) {
			if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
				return
			}
			logging.LogRequest(r).WithField("handle_read_errors", feature.HandleReadErrors.Enabled()).WithError(err).Error("error reading content")
			if feature.HandleReadErrors.Enabled() {
				errortracking.CaptureErrWithReqAndStackTrace(err, r)
				logging.LogRequest(r).WithError(err).Error("error reading content")
				httperrors.Serve500(w)
			}
		}
	}
}