Skip to content
Closed
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
25 changes: 9 additions & 16 deletions java/src/main/java/com/genexus/internet/HttpClientJavaLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,29 +718,22 @@ private void setEntityReader() throws IOException {
if (reader == null)
reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
}

public String getString() {
if (response == null)
return "";
public String getString() {
if (response == null)
return "";
try {
this.setEntity();
ContentType contentType = ContentType.getOrDefault(entity);
Charset charset;
if (contentType.equals(ContentType.DEFAULT_TEXT)) {
charset = StandardCharsets.UTF_8;
} else {
charset = contentType.getCharset();
if (charset == null) {
charset = StandardCharsets.UTF_8;
}
}
Charset charset = ContentType.getOrDefault(entity).getCharset();
String res = EntityUtils.toString(entity, charset);
if (res.matches(".*[Ã-ÿ].*")) {
res = EntityUtils.toString(entity, StandardCharsets.UTF_8);
}
eof = true;
return res;
} catch (IOException e) {
setExceptionsCatch(e);
} catch (IllegalArgumentException e) {
}
} catch (IllegalArgumentException e) {}
return "";
}

Expand Down
Loading