From cc27ca38043a6d84b16ff8a448388dcf62e698df Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 26 Jan 2023 15:42:30 +0100 Subject: [PATCH] dnsdist: Better HTTP error code for an invalid name in the cache API --- pdns/dnsdist-web.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 4db57b034e..3cfd46789d 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -350,11 +350,13 @@ static bool isMethodAllowed(const YaHTTP::Request& req) return true; } } +#ifndef DISABLE_WEB_CACHE_MANAGEMENT if (req.method == "DELETE") { if (req.url.path == "/api/v1/cache") { return true; } } +#endif /* DISABLE_WEB_CACHE_MANAGEMENT */ return false; } @@ -1501,7 +1503,7 @@ static void handleCacheManagement(const YaHTTP::Request& req, YaHTTP::Response& name = DNSName(expungeName->second); } catch (const std::exception& e) { - resp.status = 404; + resp.status = 400; Json::object obj{ { "status", "error" }, { "error", "unable to parse the requested name" }, -- 2.47.2