Catch invalid header

This commit is contained in:
some 2024-10-01 22:07:11 -04:00
parent fb4a2010d6
commit fe10226ab2
Signed by: some
GPG Key ID: 65D0589220B9BFC8

View File

@ -71,6 +71,11 @@ func (srv *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write(errRes.ErrorResponse())
srv.logger.Logf(log.LevelError, "request failed: %s", errRes.String())
}
w.WriteHeader(res.HttpStatus())
if res.HttpStatus() >= 100 {
w.WriteHeader(res.HttpStatus())
} else {
w.WriteHeader(http.StatusInternalServerError)
srv.logger.Logf(log.LevelError, "received invalid status from service (%d)", res.HttpStatus())
}
w.Write(res.Response())
}