From 98d6572164c77af7bc8b391711668e67b55a798e Mon Sep 17 00:00:00 2001 From: Bruno Volpato Date: Wed, 9 Nov 2016 21:04:01 -0800 Subject: [PATCH 1/2] Reject DELETE requests with a body FIxes #8217 --- .../elasticsearch/rest/action/document/RestDeleteAction.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java b/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java index 6478b7996649d..807227806647f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java @@ -48,6 +48,10 @@ public RestDeleteAction(Settings settings, RestController controller) { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { + if (RestActions.hasBodyContent(request)) { + throw new IllegalArgumentException("can't specify a request body"); + } + DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id")); deleteRequest.routing(request.param("routing")); deleteRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing From 290c9a74d03f9fa5455f4a7d6ce59e6829403474 Mon Sep 17 00:00:00 2001 From: Bruno Candido Volpato da Cunha Date: Wed, 11 Jan 2017 16:33:41 -0800 Subject: [PATCH 2/2] Exception message update --- .../elasticsearch/rest/action/document/RestDeleteAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java b/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java index 807227806647f..0d8d02afae764 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java @@ -49,7 +49,7 @@ public RestDeleteAction(Settings settings, RestController controller) { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { if (RestActions.hasBodyContent(request)) { - throw new IllegalArgumentException("can't specify a request body"); + throw new IllegalArgumentException("DELETE requests may not contain a request body"); } DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));