Skip to content

Commit

Permalink
JAV-571 fix bug: send response with charset
Browse files Browse the repository at this point in the history
  • Loading branch information
wujimin authored and WillemJiang committed Dec 18, 2017
1 parent d3a92bd commit 02e6827
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected void sendResponse(Response response) throws Exception {
}
}
responseEx.setStatus(response.getStatusCode(), response.getReasonPhrase());
responseEx.setContentType(produceProcessor.getName());
responseEx.setContentType(produceProcessor.getName()+"; charset=utf-8");

Object body = response.getResult();
if (response.isFailed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void setContentType(String type) {
Map<String, Object> expected = new HashMap<>();
expected.put("statusCode", 123);
expected.put("reasonPhrase", "reason");
expected.put("contentType", "application/json");
expected.put("contentType", "application/json; charset=utf-8");

initRestInvocation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,11 @@ public void ableToQueryAtRootBasePath() {
assertThat(responseEntity.getStatusCode(), is(OK));
assertThat(responseEntity.getBody(), is("Hi Mike"));

List<HttpMessageConverter<?>> convertersOld = restTemplate.getMessageConverters();
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new MappingJackson2HttpMessageConverter());
restTemplate.setMessageConverters(converters);
responseEntity = restTemplate
.getForEntity(baseUrl + "sayHi?name={name}", String.class, "小 强");

assertThat(responseEntity.getStatusCode(), is(OK));
assertThat(responseEntity.getBody(), is("Hi 小 强"));

restTemplate.setMessageConverters(convertersOld);
}

@Test
Expand Down

0 comments on commit 02e6827

Please sign in to comment.