[
https://issues.apache.org/jira/browse/HTTPCLIENT-1920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16488080#comment-16488080
]
Tobias Gesellchen commented on HTTPCLIENT-1920:
-----------------------------------------------
I've slowly started to work on a better PR, and I wanted to leave some
notes/questions here.
It's hard for me to get familiar with the codebase (especially the test setup),
probably due to my lack of detailed knowledge about the HTTP protocol and the
httpclient-cache library. That's a good chance to learn a bit ;)
One of the checks inside {{canCachedResponseBeUsed}} already seems to aim at
recognising invalid HEAD cache entries. Please have a look at
https://github.com/apache/httpcomponents-client/blob/eb71f45ee5883a6bf89d18a7e4f6558672ba3646/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java#L253
- I suppose the check always returns {{false}}, because an entry's request
method will always be non-null. Do you agree that we would only need to check
for a missing entity? Would you also agree that this is exactly the necessary
validation you mentioned as part of the "full desired behaviour"?
In cases where the suitability check fails, we still need a check to suppress
revalidation of unusable HEAD entries. This is what you already advised me to
add at {{CachingExec.java#L272}}, which I'm going to provide soonish as part of
an updated PR.
> Cached HEAD requests without response body
> ------------------------------------------
>
> Key: HTTPCLIENT-1920
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1920
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (classic)
> Affects Versions: 4.4.1, 4.5
> Reporter: Tobias Gesellchen
> Priority: Major
> Labels: pull-request-available
>
> Since httpclient-cache 4.4 {{HEAD}} requests can be cached with a {{null}}
> response body. Subsequent {{GET}} requests to the same target then use the
> headers "If-None-Match" and "If-Modified-Since" to leverage caching via HTTP
> protocol. In that case a server can respond with status code 304 and an empty
> response body, which leads to an invalid cache entry.
> The GitHub PR #101 proposes a fix, which I have tested locally. The PR is
> based on httpclient-cache 4.5, but should easily be backported to 4.4. I
> haven't looked into the upcoming 5.x sources, yet.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]