ok2c commented on code in PR #881:
URL:
https://github.com/apache/httpcomponents-client/pull/881#discussion_r3879552908
##########
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/ContentCompressionAsyncExec.java:
##########
@@ -188,6 +310,175 @@ public void failed(final Exception ex) {
});
}
+ private static List<String> createDictionaryAcceptTokens(
+ final CompressionDictionaryStore compressionDictionaryStore) {
+ final List<String> tokens = new ArrayList<>();
+ if (compressionDictionaryStore != null && Brotli4jRuntime.available())
{
+ tokens.add(ContentCoding.DCB.token());
+ }
+ if (compressionDictionaryStore != null && ZstdRuntime.available()) {
+ tokens.add(ContentCoding.DCZ.token());
+ }
+ return tokens;
+ }
+
+ private List<String> selectDictionaryAcceptTokens(
+ final CompressionDictionary dictionary) {
+ if (dictionary == null
+ || !dictionaryAcceptTokens.contains(ContentCoding.DCZ.token())
+ || isDczDictionaryCompatible(dictionary)) {
+ return dictionaryAcceptTokens;
+ }
+ final List<String> tokens = new ArrayList<>(dictionaryAcceptTokens);
+ tokens.remove(ContentCoding.DCZ.token());
+ return tokens;
+ }
+
+ private static boolean isDczDictionaryCompatible(
+ final CompressionDictionary dictionary) {
+ return dictionary.getContentLength() >= 8
+ && !dictionary.contentStartsWith(
+ (byte) 0x37, (byte) 0xa4, (byte) 0x30, (byte) 0xec);
+ }
+
+ private CompressionDictionary prepareDictionaryNegotiation(
+ final HttpRequest request,
+ final boolean enabled,
+ final CompressionDictionary candidate,
+ final List<String> requestDictionaryAcceptTokens) {
+ if (!enabled) {
+ return null;
+ }
+
+ // A caller-provided Accept-Encoding is honoured verbatim: the client
neither rewrites it
+ // nor negotiates a dictionary on top of an explicit choice.
Review Comment:
@arturobernalg Exactly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]