From ae8764760b3eca96ab309d424dc772d9e90eb1c8 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Date: Mon, 13 Dec 2010 20:25:08 +0000 Subject: [PATCH] HTTPCLIENT-1032: caching of 200 origin response from variant negotiation should be stored w.r.t. original client request. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1045360 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/impl/client/cache/CachingHttpClient.java | 5 +++-- .../apache/http/impl/client/cache/TestCachingHttpClient.java | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java index 4f5602bc7..9d89401bd 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java @@ -604,12 +604,13 @@ public class CachingHttpClient implements HttpClient { backendResponse.addHeader("Via", generateViaHeader(backendResponse)); if (backendResponse.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED) { - return handleBackendResponse(target, conditionalRequest, requestDate, responseDate, backendResponse); + return handleBackendResponse(target, request, requestDate, responseDate, backendResponse); +// return handleBackendResponse(target, conditionalRequest, requestDate, responseDate, backendResponse); } Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG); if (resultEtagHeader == null) { - log.debug("304 response did not contain ETag"); + log.warn("304 response did not contain ETag"); return callBackend(target, request, context); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java index d5f2dbec5..53e1e1139 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java @@ -1662,9 +1662,8 @@ public class TestCachingHttpClient { responsePolicyAllowsCaching(true); - EasyMock.expect(mockCache.getCacheEntry(host, variantConditionalRequest)).andReturn(cacheEntry); - - EasyMock.expect(mockCache.cacheAndReturnResponse(EasyMock.same(host), EasyMock.same(variantConditionalRequest), EasyMock.same(originResponse), EasyMock.isA(Date.class), EasyMock.isA(Date.class))).andReturn(response); + EasyMock.expect(mockCache.getCacheEntry(host, request)).andReturn(cacheEntry); + EasyMock.expect(mockCache.cacheAndReturnResponse(EasyMock.same(host), EasyMock.same(request), EasyMock.same(originResponse), EasyMock.isA(Date.class), EasyMock.isA(Date.class))).andReturn(response); replayMocks(); HttpResponse resp = impl.negotiateResponseFromVariants(host, request, context, variants);