Skip to content

Commit

Permalink
Merge pull request PowerDNS#14243 from leonshaw/fix/remote-http-rrset
Browse files Browse the repository at this point in the history
remotebackend: Fix http request of replaceRRSet
  • Loading branch information
Habbie authored Jun 4, 2024
2 parents 7417152 + 3119e85 commit c8d86e7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions modules/remotebackend/httpconnector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,12 @@ std::string HTTPConnector::buildMemberListArgs(const std::string& prefix, const
std::stringstream stream;

for (const auto& pair : args.object_items()) {
stream << prefix << "[" << YaHTTP::Utility::encodeURL(pair.first, false) << "]=";
if (pair.second.is_bool()) {
stream << (pair.second.bool_value() ? "1" : "0");
}
else if (pair.second.is_null()) {
stream << prefix << "[" << YaHTTP::Utility::encodeURL(pair.first, false) << "]=";
}
else {
stream << prefix << "[" << YaHTTP::Utility::encodeURL(pair.first, false) << "]=" << YaHTTP::Utility::encodeURL(HTTPConnector::asString(pair.second), false);
else if (!pair.second.is_null()) {
stream << YaHTTP::Utility::encodeURL(HTTPConnector::asString(pair.second), false);
}
stream << "&";
}
Expand Down Expand Up @@ -183,9 +181,9 @@ void HTTPConnector::restful_requestbuilder(const std::string& method, const Json
else if (method == "replaceRRSet") {
std::stringstream ss2;
for (size_t index = 0; index < parameters["rrset"].array_items().size(); index++) {
ss2 << buildMemberListArgs("rrset[" + std::to_string(index) + "]", parameters["rrset"][index]);
ss2 << buildMemberListArgs("rrset[" + std::to_string(index) + "]", parameters["rrset"][index]) << "&";
}
req.body = ss2.str();
req.body = ss2.str().substr(0, ss2.str().size() - 1); // remove trailing &
req.headers["content-type"] = "application/x-www-form-urlencoded; charset=utf-8";
req.headers["content-length"] = std::to_string(req.body.size());
verb = "PATCH";
Expand Down

0 comments on commit c8d86e7

Please sign in to comment.