RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java,v retrieving revision 1.33 diff -u -r1.33 HttpMethodDirector.java --- HttpMethodDirector.java 19 Dec 2004 16:21:42 -0000 1.33 +++ HttpMethodDirector.java 9 Jan 2005 14:36:26 -0000 @@ -588,22 +588,43 @@ return false; } + //since the redirectUri could be changed in code above (deleting + //query part - in order to log proper message, we want to save + //full original uri for redirection + String redirectUriString = null; + if(LOG.isDebugEnabled()) { + redirectUriString = redirectUri.getEscapedURI(); + } + if (this.params.isParameterFalse(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS)) { if (this.redirectLocations == null) { this.redirectLocations = new HashSet(); } this.redirectLocations.add(currentUri); - if (this.redirectLocations.contains(redirectUri)) { - throw new RedirectException("Circular redirect to '" + - redirectUri + "'"); + try { + if(redirectUri.hasQuery()) { + int index = location.indexOf('?'); + if(index >=0) { + location = location.substring(0, index); + redirectUri = new URI(redirectUri, location, true); + } + } + + if (this.redirectLocations.contains(redirectUri)) { + throw new RedirectException("Circular redirect to '" + + redirectUri + "'"); + } } + catch (URIException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } if (LOG.isDebugEnabled()) { LOG.debug("Redirecting from '" + currentUri.getEscapedURI() - + "' to '" + redirectUri.getEscapedURI()); + + "' to '" + redirectUriString); } - //And finally invalidate the actual authentication scheme method.getHostAuthState().invalidate(); return true;