Fixed incorrect handling of redirect locations with the query component

Contributed by Johannes Koch <johannes.koch at fit.fraunhofer.de>  
Reviewed by Oleg Kalnichevski

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@610838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2008-01-10 16:31:32 +00:00
parent 5709949205
commit dfffbc9a3c
2 changed files with 4 additions and 6 deletions

View File

@ -143,7 +143,7 @@ public class DefaultRedirectHandler implements RedirectHandler {
target.getPort(),
requestURI.getPath(),
requestURI.getQuery(),
requestURI.getFragment());
null);
uri = absoluteRequestURI.resolve(uri);
} catch (URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
@ -169,7 +169,7 @@ public class DefaultRedirectHandler implements RedirectHandler {
uri.getHost(),
uri.getPort(),
uri.getPath(),
null,
uri.getQuery(),
null);
} catch (URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);

View File

@ -131,8 +131,6 @@ public class TestRedirects extends ServerTestBase {
private class CircularRedirectService implements HttpRequestHandler {
private int invocations = 0;
public CircularRedirectService() {
super();
}
@ -145,10 +143,10 @@ public class TestRedirects extends ServerTestBase {
String uri = request.getRequestLine().getUri();
if (uri.startsWith("/circular-oldlocation")) {
response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
response.addHeader(new BasicHeader("Location", "/circular-location2?invk=" + (++this.invocations)));
response.addHeader(new BasicHeader("Location", "/circular-location2"));
} else if (uri.startsWith("/circular-location2")) {
response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
response.addHeader(new BasicHeader("Location", "/circular-oldlocation?invk=" + (++this.invocations)));
response.addHeader(new BasicHeader("Location", "/circular-oldlocation"));
} else {
response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
}