From 7530364ddbe949bc34fc26f25ba3f5d921beb021 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 21 Oct 2011 23:51:39 +0200 Subject: [PATCH] Accept both PUT and POST in noded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, noded requires PUT, even though the semantics of the RPC calls do not match a PUT. We change the code accept both PUT and POST, with the intention to remove the PUT support in a later version. On the client side, the RPC code is changed to send POST requests. Additionally, we add a message to the HttpBadRequest exception to make clear the failure mode (not seeing any error message was what made me send this patchβ¦). This was the only description-less use of this exception, by the way. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- lib/rpc.py | 2 +- lib/server/noded.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rpc.py b/lib/rpc.py index 3fd8e72df..437df9817 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -362,7 +362,7 @@ class _RpcProcessor: else: requests[name] = \ http.client.HttpClientRequest(str(ip), port, - http.HTTP_PUT, str("/%s" % procedure), + http.HTTP_POST, str("/%s" % procedure), headers=_RPC_CLIENT_HEADERS, post_data=body[name], read_timeout=read_timeout, diff --git a/lib/server/noded.py b/lib/server/noded.py index 22091d7c1..3495526a4 100644 --- a/lib/server/noded.py +++ b/lib/server/noded.py @@ -138,8 +138,9 @@ class NodeHttpServer(http.server.HttpServer): """Handle a request. """ - if req.request_method.upper() != http.HTTP_PUT: - raise http.HttpBadRequest() + # FIXME: Remove HTTP_PUT in Ganeti 2.7 + if req.request_method.upper() not in (http.HTTP_PUT, http.HTTP_POST): + raise http.HttpBadRequest("Only PUT and POST methods are supported") path = req.request_path if path.startswith("/"): -- GitLab