From d3e86bbebacc12834e3c188851f588ceac1548fe Mon Sep 17 00:00:00 2001 From: Howard Wu Date: Tue, 9 Jul 2024 13:49:49 +1200 Subject: [PATCH] fix: no message body reponsed when the query returns no content --- cmd/fdsn-ws/routes.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/fdsn-ws/routes.go b/cmd/fdsn-ws/routes.go index 76b276ae..00a1631d 100644 --- a/cmd/fdsn-ws/routes.go +++ b/cmd/fdsn-ws/routes.go @@ -104,8 +104,11 @@ func fdsnErrorHandler(err error, h http.Header, b *bytes.Buffer, nounce string) default: } - msg := fmt.Sprintf(FDSN_ERR_FORMAT, e.Code, http.StatusText(e.Code), e.Err, e.url, e.timestamp.Format(time.RFC3339), ver) - b.WriteString(msg) + // "no content" can't have a http body + if e.Code != http.StatusNoContent && e.Code != http.StatusNotFound { + msg := fmt.Sprintf(FDSN_ERR_FORMAT, e.Code, http.StatusText(e.Code), e.Err, e.url, e.timestamp.Format(time.RFC3339), ver) + b.WriteString(msg) + } return nil }