Skip to content

Commit

Permalink
Tweak default encoding behavior to match prior behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 1, 2024
1 parent ab020a7 commit 916e9f5
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ static Optional<Encoding> get(String name) {
}
}

private static boolean isHttpClientV4InClasspath() {
try {
Class.forName("org.apache.http.client.utils.URLEncodedUtils");
return true;
} catch (Exception ignored) {
return false;
}
}

private static final String ENCODING_PROPERTY = "org.opensearch.path.encoding";
private static final Encoding ENCODING_DEFAULT = Encoding.HTTP_CLIENT_V5_EQUIV;
private static final Encoding ENCODING_DEFAULT = isHttpClientV4InClasspath()
? Encoding.HTTP_CLIENT_V4_EQUIV
: Encoding.HTTP_CLIENT_V5_EQUIV;

private static final Encoding ENCODING = Optional.ofNullable(System.getProperty(ENCODING_PROPERTY))
.flatMap(Encoding::get)
Expand Down

0 comments on commit 916e9f5

Please sign in to comment.