diff options
author | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2016-09-14 14:34:10 +0200 |
---|---|---|
committer | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2016-09-14 14:34:10 +0200 |
commit | ad9c0199b35556615a321dbd258ec5cd54ec448d (patch) | |
tree | b1ac73f638c3ccf2c4c229d62cf3a0bed2acbf09 /vespaclient-container-plugin | |
parent | 13b85c3554248a17ac3f54f5a8ed87f09c42cc26 (diff) |
Set correct content-type.
Diffstat (limited to 'vespaclient-container-plugin')
2 files changed, 5 insertions, 0 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java index c016241c095..8d2268b0d1f 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java @@ -189,6 +189,8 @@ public class RestApi extends LoggingRequestHandler { return new HttpResponse(getDocument.isPresent() ? 200 : 404) { @Override + public String getContentType() { return "application/json"; } + @Override public void render(OutputStream outputStream) throws IOException { outputStream.write(resultNode.toString().getBytes(StandardCharsets.UTF_8.name())); } @@ -216,6 +218,8 @@ public class RestApi extends LoggingRequestHandler { HttpResponse httpResponse = new HttpResponse(200) { @Override + public String getContentType() { return "application/json"; } + @Override public void render(OutputStream outputStream) throws IOException { try { outputStream.write(resultNode.toString().getBytes(StandardCharsets.UTF_8)); diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java index 036dc63ad34..c4e9e27ca75 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java @@ -285,6 +285,7 @@ public class RestApiTest { private String doRest(HttpRequestBase request) throws IOException { HttpClient client = HttpClientBuilder.create().build(); HttpResponse response = client.execute(request); + assertThat(response.getEntity().getContentType().getValue().toString(), is("application/json; charset=UTF-8")); HttpEntity entity = response.getEntity(); return EntityUtils.toString(entity); } |