Incorrect processing of Vary: HTTP header of cacheable server response
----------------------------------------------------------------------
Key: HTTPCLIENT-1163
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1163
Project: HttpComponents HttpClient
Issue Type: Bug
Components: Cache
Affects Versions: Snapshot
Reporter: Manish Tripathi
Vary header from the server's response is not processed correctly by the cache
when prepending the list of variables to the URL.
Example (unrelated headers removed from the requests/responses for clarity).
-> client sends:
GET http://s.ytimg.com/yt/cssbin/www-guide-vflgAVfxE.css HTTP/1.1
Accept-Encoding: gzip, deflate
Host: s.ytimg.com
-> server responds:
HTTP/1.1 200 OK
Vary: Accept-Encoding
Current implementation produces the following variant URI to be stored in the
cache:
{Accept-Encoding=}http://s.ytimg.com/yt/cssbin/www-guide-vflgAVfxE.css
Notice how the actual value of Accept-Encoding header from the original request
is NOT prepended.
The correct variant URI should be:
{Accept-Encoding=gzip%2Cdeflate}http://s.ytimg.com/yt/cssbin/www-guide-vflgAVfxE.css
The cause of the problem:
org.apache.http.impl.client.cache.CachingHttpClient.java, method callBackend(..)
uses the original version of HttpRequest without headers added by
DefaultHttpClient and/or ContentEncodingHttpClient implementation.
Proposed fix:
Replace the following lines of
org.apache.http.impl.client.cache.CachingHttpClient.java:
HttpResponse backendResponse = backend.execute(target, request,
context);
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
return handleBackendResponse(target, request, requestDate,
getCurrentDate(),
backendResponse);
with the lines:
if (context==null) context=new BasicHttpContext();
HttpResponse backendResponse = backend.execute(target, request,
context);
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
HttpRequest
actualRequest=(HttpRequest)context.getAttribute(ExecutionContext.HTTP_REQUEST);
return handleBackendResponse(target, actualRequest, requestDate,
getCurrentDate(),
backendResponse);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]