desiderantes commented on code in PR #850:
URL:
https://github.com/apache/httpcomponents-client/pull/850#discussion_r3589389448
##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheKeyGenerator.java:
##########
@@ -135,9 +140,33 @@ public String generateKey(final URI requestUri) {
* @param host The host for this request
* @param request the {@link HttpRequest}
* @return cache key
+ *
+ * @deprecated Use {@link #generateKey(HttpHost, HttpRequest, Function)}
*/
+ @Deprecated
public String generateKey(final HttpHost host, final HttpRequest request) {
+ return generateKey(host, request, r -> null);
+ }
+
+ /**
+ * Computes a root key for the given {@link HttpHost}, {@link HttpRequest}
and
+ * request body that can be used as a unique identifier for cached
resources.
+ *
+ * @param host The host for this request
+ * @param request the {@link HttpRequest}
+ * @param bodyExtractor function to extract request body. May be {@code
null}
+ * @return cache key
+ *
+ * @since 5.7
+ */
+ public <T extends HttpRequest> String generateKey(final HttpHost host,
+ final T request,
+ final Function<T,
String> bodyExtractor) {
final String s = CacheSupport.requestUriRaw(host, request);
+ final String body = bodyExtractor != null ?
bodyExtractor.apply(request) : null;
+ if (body != null) {
Review Comment:
Is it supposed to fail now if the body extractor succeeds?
--
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]