arturobernalg commented on code in PR #449:
URL:
https://github.com/apache/httpcomponents-client/pull/449#discussion_r1199658427
##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java:
##########
@@ -58,26 +56,17 @@
public T buildConditionalRequest(final T request, final HttpCacheEntry
cacheEntry) {
final T newRequest = messageCopier.create(request);
- final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
+ final Header eTag = cacheEntry.getFirstHeader(HttpHeaders.ETAG);
if (eTag != null) {
- newRequest.setHeader(HeaderConstants.IF_NONE_MATCH,
eTag.getValue());
+ newRequest.setHeader(HttpHeaders.IF_NONE_MATCH, eTag.getValue());
}
- final Header lastModified =
cacheEntry.getFirstHeader(HeaderConstants.LAST_MODIFIED);
+ final Header lastModified =
cacheEntry.getFirstHeader(HttpHeaders.LAST_MODIFIED);
if (lastModified != null) {
- newRequest.setHeader(HeaderConstants.IF_MODIFIED_SINCE,
lastModified.getValue());
+ newRequest.setHeader(HttpHeaders.IF_MODIFIED_SINCE,
lastModified.getValue());
}
- boolean mustRevalidate = false;
- final Iterator<HeaderElement> it = MessageSupport.iterate(cacheEntry,
HeaderConstants.CACHE_CONTROL);
- while (it.hasNext()) {
- final HeaderElement elt = it.next();
- if
(HeaderConstants.CACHE_CONTROL_MUST_REVALIDATE.equalsIgnoreCase(elt.getName())
- ||
HeaderConstants.CACHE_CONTROL_PROXY_REVALIDATE.equalsIgnoreCase(elt.getName()))
{
- mustRevalidate = true;
- break;
- }
- }
- if (mustRevalidate) {
- newRequest.addHeader(HeaderConstants.CACHE_CONTROL,
HeaderConstants.CACHE_CONTROL_MAX_AGE + "=0");
+ final ResponseCacheControl cacheControl =
CacheControlHeaderParser.INSTANCE.parse(cacheEntry);
Review Comment:
Similarly, since we already possess the ResponseCacheControl, we should
simply pass it as a parameter
--
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]