Merge pull request #258 from sgotti/gitserver_fix_fetchfile_errors

gitserver: fix fetchfile error handling
This commit is contained in:
Simone Gotti 2021-03-15 15:17:13 +01:00 committed by GitHub
commit 69a5e0fe9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -266,8 +266,13 @@ func (h *FetchFileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
if err := gitFetchFile(ctx, w, r.Body, repoAbsPath, fetchData.Ref, fetchData.Path); err != nil { if err := gitFetchFile(ctx, w, r.Body, repoAbsPath, fetchData.Ref, fetchData.Path); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
// we cannot return any http error since the http header has already been written
h.log.Errorf("git command error: %v", err) h.log.Errorf("git command error: %v", err)
// since we already answered with a 200 we cannot return another error code
// So abort the connection and the client will detect the missing ending chunk
// and consider this an error
//
// this is the way to force close a request without logging the panic
panic(http.ErrAbortHandler)
} }
} }