diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java index 6bea98854d4..00c76fbc24e 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java @@ -76,7 +76,7 @@ public class RestAnalyzeAction extends BaseRestHandler { @Override public void onResponse(AnalyzeResponse response) { try { - XContentBuilder builder = restContentBuilder(request); + XContentBuilder builder = restContentBuilder(request, false); builder.startObject(); response.toXContent(builder, request); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java b/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java index fe4c64d9466..d94a37247ff 100644 --- a/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java +++ b/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java @@ -35,10 +35,14 @@ import java.io.IOException; public class RestXContentBuilder { public static XContentBuilder restContentBuilder(RestRequest request) throws IOException { + return restContentBuilder(request, true); + } + + public static XContentBuilder restContentBuilder(RestRequest request, boolean autoDetect) throws IOException { XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type"))); if (contentType == null) { // try and guess it from the body, if exists - if (request.hasContent()) { + if (autoDetect && request.hasContent()) { contentType = XContentFactory.xContentType(request.content()); } }