diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/xcontent/XContentType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/xcontent/XContentType.java index c33e370f48b..205f488f971 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/xcontent/XContentType.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/xcontent/XContentType.java @@ -29,11 +29,17 @@ public enum XContentType { /** * A JSON based content type. */ - JSON(0), + JSON(0) { + @Override public String restContentType() { + return "application/json; charset=UTF-8"; + }}, /** * The jackson based smile binary format. Fast and compact binary format. */ - SMILE(1); + SMILE(1) { + @Override public String restContentType() { + return "application/smile"; + }}; public static XContentType fromRestContentType(String contentType) { if (contentType == null) { @@ -59,4 +65,6 @@ public enum XContentType { public int index() { return index; } + + public abstract String restContentType(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/XContentRestResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/XContentRestResponse.java index bf99fa8fcf8..be4240318ec 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/XContentRestResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/XContentRestResponse.java @@ -64,7 +64,7 @@ public class XContentRestResponse extends AbstractRestResponse { } @Override public String contentType() { - return "application/json; charset=UTF-8"; + return builder.contentType().restContentType(); } @Override public boolean contentThreadSafe() {