From 6681a1193d89c74f76cd58a7b124eaf67f85f103 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Mon, 1 Jun 2009 10:39:05 +0000 Subject: [PATCH] HTTPCLIENT-852: Fixed bug causing automatically retried redirects fail with CircularRedirectException git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@780611 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE_NOTES.txt | 4 ++++ .../org/apache/http/impl/client/DefaultRequestDirector.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 196d7585e..62ab4395d 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,10 @@ Changes since 4.0 beta 2 ------------------- +* [HTTPCLIENT-852] Fixed bug causing automatically retried redirects fail with + CircularRedirectException. + Contributed by Oleg Kalnichevski + * Fixed problem with the default HTTP response parser failing to handle garbage preceding a valid HTTP response. Contributed by Oleg Kalnichevski diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java index 89fff0b9f..3083a33a7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java @@ -333,9 +333,9 @@ public class DefaultRequestDirector implements RequestDirector { int execCount = 0; boolean reuse = false; - HttpResponse response = null; boolean done = false; try { + HttpResponse response = null; while (!done) { // In this loop, the RoutedRequest may be replaced by a // followup request and route. The request and route passed @@ -344,6 +344,7 @@ public class DefaultRequestDirector implements RequestDirector { RequestWrapper wrapper = roureq.getRequest(); HttpRoute route = roureq.getRoute(); + response = null; // See if we have a user token bound to the execution context Object userToken = context.getAttribute(ClientContext.USER_TOKEN); @@ -471,7 +472,7 @@ public class DefaultRequestDirector implements RequestDirector { // If we have a direct route to the target host // just re-open connection and re-try the request - if (route.getHopCount() == 1) { + if (!route.isTunnelled()) { this.log.debug("Reopening the direct connection."); managedConn.open(route, context, params); } else {