]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4460] fixed netconf http connection reply
authorRazvan Becheriu <razvan@isc.org>
Wed, 22 Apr 2026 14:34:30 +0000 (17:34 +0300)
committerAndrei Pavel <andrei@isc.org>
Mon, 25 May 2026 06:22:51 +0000 (09:22 +0300)
src/bin/netconf/http_control_socket.cc
src/bin/netconf/tests/control_socket_unittests.cc

index 009b1c41dd7da829dbf5e883550eee7014533c71..8c6edb036aa2f13717d5c588f41b16ec631d2a18 100644 (file)
@@ -110,7 +110,12 @@ HttpControlSocket::sendCommand(ConstElementPtr command) {
     }
 
     try {
-        return (response->getBodyAsJson());
+        auto response_list = response->getBodyAsJson();
+        if (response_list->getType() != Element::list) {
+            isc_throw(CtrlChannelError, "invalid answer: expected toplevel entry to be a list, got "
+                      << Element::typeToName(response_list->getType()) << " instead");
+        }
+        return (response_list->get(0));
     } catch (exception const& ex) {
         isc_throw(ControlSocketError, "unparsable response: " << ex.what());
     }
index 4ab40dcefc627e0ffbd1e1a751450f20e3f48470..1cb3e7321c1766c13e3cf727d8d1712465501787 100644 (file)
@@ -492,7 +492,9 @@ protected:
                                           HttpStatusCode::OK));
         ElementPtr map = Element::createMap();
         map->set("received", Element::create(body->str()));
-        response->setBodyAsJson(map);
+        ElementPtr response_list = Element::createList();
+        response_list->add(boost::const_pointer_cast<Element>(map));
+        response->setBodyAsJson(response_list);
         response->finalize();
         return (response);
     }