From 65cb252c9b2fba6171dfa9366314ab46737b0d00 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Date: Mon, 20 Dec 2010 12:51:26 +0000 Subject: [PATCH] HTTPCLIENT-975: more method extraction from the body of CachingHttpClient#execute() git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1051087 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/client/cache/CachingHttpClient.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 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 5e8e4bcc4..bf36cca4d 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 @@ -383,12 +383,9 @@ public class CachingHttpClient implements HttpClient { return new OptionsHttp11Response(); } - List fatalError = requestCompliance.requestIsFatallyNonCompliant(request); - - for (RequestProtocolError error : fatalError) { - setResponseStatus(context, CacheResponseStatus.CACHE_MODULE_RESPONSE); - return requestCompliance.getErrorForRequest(error); - } + HttpResponse fatalErrorResponse = getFatallyNoncompliantResponse( + request, context); + if (fatalErrorResponse != null) return fatalErrorResponse; request = requestCompliance.makeRequestCompliant(request); request.addHeader("Via",via); @@ -452,7 +449,20 @@ public class CachingHttpClient implements HttpClient { throw new ClientProtocolException(e); } } - return callBackend(target, request, context); + return callBackend(target, request, context); + + } + + private HttpResponse getFatallyNoncompliantResponse(HttpRequest request, + HttpContext context) { + HttpResponse fatalErrorResponse = null; + List fatalError = requestCompliance.requestIsFatallyNonCompliant(request); + + for (RequestProtocolError error : fatalError) { + setResponseStatus(context, CacheResponseStatus.CACHE_MODULE_RESPONSE); + fatalErrorResponse = requestCompliance.getErrorForRequest(error); + } + return fatalErrorResponse; } private Map getExistingCacheVariants(HttpHost target,