From 3ae63ca8496d9f2be99f066bbe489cfee11363d9 Mon Sep 17 00:00:00 2001 From: Konrad Wojas Date: Fri, 15 Sep 2017 13:56:38 +0800 Subject: [PATCH] auth api: return new serial in header after PATCH For zone PATCH requests, this adds a new `X-PDNS-Zone-Serial` response header with the new zone serial. Ideally this would be returned in a response JSON object, but this API currently return 204 No Content and I did not want to break any clients that might rely on this. --- docs/http-api/endpoint-zones.rst | 2 ++ pdns/ws-auth.cc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/docs/http-api/endpoint-zones.rst b/docs/http-api/endpoint-zones.rst index 4e82e1f0f..6c3627b53 100644 --- a/docs/http-api/endpoint-zones.rst +++ b/docs/http-api/endpoint-zones.rst @@ -42,6 +42,8 @@ Zones endpoint Modifies present RRsets and comments. Returns ``204 No Content`` on success. + The new zone serial will be returned in an `X-PDNS-Zone-Serial` header (auth 4.1+). + :param server_id: The name of the server :param zone_id: The id number of the :json:object:`Zone` diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index dc567135b..cfad4fc9c 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -1499,6 +1499,10 @@ static void patchZone(HttpRequest* req, HttpResponse* resp) { if (!di.backend->replaceRRSet(di.id, rr.qname, rr.qtype, vector(1, rr))) { throw ApiException("Hosting backend does not support editing records."); } + + // return new serial in a header + fillSOAData(rr.content, sd); + resp->headers["X-PDNS-Zone-Serial"] = std::to_string(sd.serial); } } catch(...) { -- 2.40.0