From fe10226ab2e1fcc4498b3c3e4c8327bf6e353364 Mon Sep 17 00:00:00 2001 From: some Date: Tue, 1 Oct 2024 22:07:11 -0400 Subject: [PATCH] Catch invalid header --- server/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 7d77d7d..49d5f85 100644 --- a/server/server.go +++ b/server/server.go @@ -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()) }