DefaultRedirectStrategy to use URIUtils#normalizeSyntax method to normalize redirect location URI
This commit is contained in:
parent
4a463ebf4e
commit
be77dc917f
|
@ -354,13 +354,14 @@ public class URIUtils {
|
|||
*
|
||||
* @param uri the original URI
|
||||
* @return the URI without dot segments
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
static URI normalizeSyntax(final URI uri) throws URISyntaxException {
|
||||
public static URI normalizeSyntax(final URI uri) throws URISyntaxException {
|
||||
if (uri.isOpaque() || uri.getAuthority() == null) {
|
||||
// opaque and file: URIs
|
||||
return uri;
|
||||
}
|
||||
Args.check(uri.isAbsolute(), "Base URI must be absolute");
|
||||
final URIBuilder builder = new URIBuilder(uri);
|
||||
final List<String> inputSegments = URLEncodedUtils.parsePathSegments(uri.getPath());
|
||||
final Stack<String> outputSegments = new Stack<String>();
|
||||
|
|
|
@ -146,13 +146,14 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
|
|||
final RequestConfig config = clientContext.getRequestConfig();
|
||||
|
||||
URI uri = createLocationURI(location);
|
||||
if (config.isNormalizeUri()) {
|
||||
uri = uri.normalize();
|
||||
}
|
||||
|
||||
// rfc2616 demands the location value be a complete URI
|
||||
// Location = "Location" ":" absoluteURI
|
||||
try {
|
||||
if (config.isNormalizeUri()) {
|
||||
uri = URIUtils.normalizeSyntax(uri);
|
||||
}
|
||||
|
||||
// rfc2616 demands the location value be a complete URI
|
||||
// Location = "Location" ":" absoluteURI
|
||||
if (!uri.isAbsolute()) {
|
||||
if (!config.isRelativeRedirectsAllowed()) {
|
||||
throw new ProtocolException("Relative redirect location '"
|
||||
|
|
Loading…
Reference in New Issue