Commit 7530364d authored by Iustin Pop's avatar Iustin Pop
Browse files

Accept both PUT and POST in noded



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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 4c1a464b
......@@ -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,
......
......@@ -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("/"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment