Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Fixed problem with non-ASCII characters in response #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -559,6 +560,7 @@ private void outputResponse(ResponseEntity<String> response, StringBuilder buffe
private class RequestHelper implements RequestCallback,
ResponseExtractor<ResponseEntity<String>> {

private final Charset utf8 = Charset.forName("UTF-8");
private Object body;
private MediaType contentType;
private HttpMessageConverterExtractor<String> extractor =
Expand Down Expand Up @@ -606,11 +608,11 @@ private RequestHelper(Object body, MediaType contentType) {
if(null != body && null != ct && ct.getSubtype().endsWith("json")) {
// Pretty-print the JSON
if(body.startsWith("{")) {
lastResult = mapper.readValue(body.getBytes(), Map.class);
lastResult = mapper.readValue(body.getBytes(utf8), Map.class);
} else if(body.startsWith("[")) {
lastResult = mapper.readValue(body.getBytes(), List.class);
lastResult = mapper.readValue(body.getBytes(utf8), List.class);
} else {
lastResult = new String(body.getBytes());
lastResult = new String(body.getBytes(utf8));
}

contextCmds.variables.put("responseBody", lastResult);
Expand Down