From: Konrad Wojas Date: Fri, 15 Sep 2017 06:39:32 +0000 (+0800) Subject: auth api: also return old serial from PATCH X-Git-Tag: rec-4.1.0-rc1~38^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5696%2Fhead;p=thirdparty%2Fpdns.git auth api: also return old serial from PATCH This adds the old serial as X-PDNS-Old-Serial and renames the header of the new one to match. The old serial is useful to verify that no other PATCH happened in the meantime. --- diff --git a/docs/http-api/endpoint-zones.rst b/docs/http-api/endpoint-zones.rst index 6c3627b534..a0b6b81929 100644 --- a/docs/http-api/endpoint-zones.rst +++ b/docs/http-api/endpoint-zones.rst @@ -42,7 +42,7 @@ 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+). + The new and old zone serials will be returned in `X-PDNS-New-Serial` and `X-PDNS-Old-Serial` headers (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 cfad4fc9c6..5e2576719f 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -1500,9 +1500,10 @@ static void patchZone(HttpRequest* req, HttpResponse* resp) { throw ApiException("Hosting backend does not support editing records."); } - // return new serial in a header + // return old and new serials in headers + resp->headers["X-PDNS-Old-Serial"] = std::to_string(sd.serial); fillSOAData(rr.content, sd); - resp->headers["X-PDNS-Zone-Serial"] = std::to_string(sd.serial); + resp->headers["X-PDNS-New-Serial"] = std::to_string(sd.serial); } } catch(...) {