Cleanups in CachingExec and related test classes
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1572556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9c02dde2cc
commit
b3b1b712df
|
@ -579,8 +579,8 @@ public class CachingExec implements ClientExecChain {
|
|||
final CloseableHttpResponse backendResponse = backend.execute(route, request, context, execAware);
|
||||
try {
|
||||
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
|
||||
return handleBackendResponse(route, request, context, execAware,
|
||||
requestDate, getCurrentDate(), backendResponse);
|
||||
return handleBackendResponse(request, context, requestDate, getCurrentDate(),
|
||||
backendResponse);
|
||||
} catch (final IOException ex) {
|
||||
backendResponse.close();
|
||||
throw ex;
|
||||
|
@ -629,9 +629,8 @@ public class CachingExec implements ClientExecChain {
|
|||
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
|
||||
|
||||
if (backendResponse.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED) {
|
||||
return handleBackendResponse(
|
||||
route, request, context, execAware,
|
||||
requestDate, responseDate, backendResponse);
|
||||
return handleBackendResponse(request, context, requestDate, responseDate,
|
||||
backendResponse);
|
||||
}
|
||||
|
||||
final Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG);
|
||||
|
@ -784,9 +783,8 @@ public class CachingExec implements ClientExecChain {
|
|||
backendResponse.close();
|
||||
}
|
||||
}
|
||||
return handleBackendResponse(
|
||||
route, conditionalRequest, context, execAware,
|
||||
requestDate, responseDate, backendResponse);
|
||||
return handleBackendResponse(conditionalRequest, context, requestDate, responseDate,
|
||||
backendResponse);
|
||||
}
|
||||
|
||||
private boolean staleIfErrorAppliesTo(final int statusCode) {
|
||||
|
@ -797,10 +795,8 @@ public class CachingExec implements ClientExecChain {
|
|||
}
|
||||
|
||||
CloseableHttpResponse handleBackendResponse(
|
||||
final HttpRoute route,
|
||||
final HttpRequestWrapper request,
|
||||
final HttpClientContext context,
|
||||
final HttpExecutionAware execAware,
|
||||
final Date requestDate,
|
||||
final Date responseDate,
|
||||
final CloseableHttpResponse backendResponse) throws IOException {
|
||||
|
|
|
@ -262,10 +262,8 @@ public class TestCachingExec extends TestCachingExecChain {
|
|||
backendExpectsRequestAndReturn(validate, originResponse);
|
||||
getCurrentDateReturns(responseDate);
|
||||
expect(impl.handleBackendResponse(
|
||||
eq(route),
|
||||
same(validate),
|
||||
same(context),
|
||||
(HttpExecutionAware) isNull(),
|
||||
eq(requestDate),
|
||||
eq(responseDate),
|
||||
same(originResponse))).andReturn(finalResponse);
|
||||
|
@ -404,10 +402,8 @@ public class TestCachingExec extends TestCachingExecChain {
|
|||
throws IOException {
|
||||
expect(
|
||||
impl.handleBackendResponse(
|
||||
isA(HttpRoute.class),
|
||||
same(request),
|
||||
isA(HttpClientContext.class),
|
||||
(HttpExecutionAware) isNull(),
|
||||
isA(Date.class),
|
||||
isA(Date.class),
|
||||
isA(CloseableHttpResponse.class))).andReturn(
|
||||
|
|
|
@ -106,7 +106,7 @@ public class TestHttpCacheJiraNumber1147 {
|
|||
EasyMock.expect(backend.execute(
|
||||
EasyMock.eq(route),
|
||||
EasyMock.isA(HttpRequestWrapper.class),
|
||||
EasyMock.same(context),
|
||||
EasyMock.isA(HttpClientContext.class),
|
||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
|
||||
EasyMock.replay(backend);
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class TestHttpCacheJiraNumber1147 {
|
|||
EasyMock.expect(backend.execute(
|
||||
EasyMock.eq(route),
|
||||
EasyMock.isA(HttpRequestWrapper.class),
|
||||
EasyMock.same(context),
|
||||
EasyMock.isA(HttpClientContext.class),
|
||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
|
||||
EasyMock.replay(backend);
|
||||
|
||||
|
|
Loading…
Reference in New Issue