private Charset getEncoding(HttpResponse response) { ContentType contentType = ContentType.getLenient(response.getEntity()); if (contentType != null && contentType.getCharset() != null) { return contentType.getCharset(); } else { return StandardCharsets.UTF_8; } } }