Skip to content

Commit 6c7fdca

Browse files
authored
Getting the result of an HTTP call was not correctly taking into account the content-type charset (#1006)
Issue: 205854
1 parent 6cc0bca commit 6c7fdca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,11 +767,12 @@ public String getString() {
767767
return "";
768768
try {
769769
this.setEntity();
770-
Charset charset = ContentType.getOrDefault(response.getEntity()).getCharset();
770+
ContentType contentType = ContentType.getOrDefault(response.getEntity());
771+
Charset charset = contentType.getCharset() != null
772+
? contentType.getCharset()
773+
: StandardCharsets.UTF_8;
774+
771775
String res = EntityUtils.toString(entity, charset);
772-
if (res.matches(".*[Ã-ÿ].*")) {
773-
res = EntityUtils.toString(entity, StandardCharsets.UTF_8);
774-
}
775776
eof = true;
776777
return res;
777778
} catch (IOException e) {

0 commit comments

Comments
 (0)