openwrt-feed/mosdns/patches/203-add-response-for-bad-request-in-ServeHTTP-handler.patch

24 lines
704 B
Diff

From 0b86b89629f32e7c8b859239aa1a4814f256053c Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Thu, 28 Sep 2023 16:42:54 +0800
Subject: [PATCH 3/5] add response for bad request in ServeHTTP handler
---
pkg/server/http_handler.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/pkg/server/http_handler.go b/pkg/server/http_handler.go
index 5a41314..8f33b3f 100644
--- a/pkg/server/http_handler.go
+++ b/pkg/server/http_handler.go
@@ -93,6 +93,7 @@ func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if err != nil {
h.warnErr(req, "invalid request", err)
w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte("Bad Request"))
return
}
--
2.42.0