HTTPCLIENT-746: Refactored URLUtils into URLEncodedUtils and URIUtils
Contributed by Stojce Dimski <sdmiski at yahoo.it> Reviewed by Oleg Kalnichevski git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@645072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1ac27569a
commit
e8923010c7
|
@ -34,7 +34,7 @@ import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
|
|
||||||
public class URLUtils {
|
public class URIUtils {
|
||||||
|
|
||||||
public static URI createURI(
|
public static URI createURI(
|
||||||
final String scheme,
|
final String scheme,
|
||||||
|
@ -81,7 +81,7 @@ public class URLUtils {
|
||||||
throw new IllegalArgumentException("URI may nor be null");
|
throw new IllegalArgumentException("URI may nor be null");
|
||||||
}
|
}
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
return URLUtils.createURI(
|
return URIUtils.createURI(
|
||||||
target.getSchemeName(),
|
target.getSchemeName(),
|
||||||
target.getHostName(),
|
target.getHostName(),
|
||||||
target.getPort(),
|
target.getPort(),
|
||||||
|
@ -89,7 +89,7 @@ public class URLUtils {
|
||||||
uri.getRawQuery(),
|
uri.getRawQuery(),
|
||||||
dropFragment ? null : uri.getRawFragment());
|
dropFragment ? null : uri.getRawFragment());
|
||||||
} else {
|
} else {
|
||||||
return URLUtils.createURI(
|
return URIUtils.createURI(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
-1,
|
-1,
|
||||||
|
@ -114,7 +114,7 @@ public class URLUtils {
|
||||||
* @return the resulting URI
|
* @return the resulting URI
|
||||||
*/
|
*/
|
||||||
public static URI resolve(final URI baseURI, final String reference) {
|
public static URI resolve(final URI baseURI, final String reference) {
|
||||||
return URLUtils.resolve(baseURI, URI.create(reference));
|
return URIUtils.resolve(baseURI, URI.create(reference));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,7 @@ public class URLUtils {
|
||||||
/**
|
/**
|
||||||
* This class should not be instantiated.
|
* This class should not be instantiated.
|
||||||
*/
|
*/
|
||||||
private URLUtils() {
|
private URIUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -67,7 +67,7 @@ import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.params.ClientPNames;
|
import org.apache.http.client.params.ClientPNames;
|
||||||
import org.apache.http.client.params.HttpClientParams;
|
import org.apache.http.client.params.HttpClientParams;
|
||||||
import org.apache.http.client.protocol.ClientContext;
|
import org.apache.http.client.protocol.ClientContext;
|
||||||
import org.apache.http.client.utils.URLUtils;
|
import org.apache.http.client.utils.URIUtils;
|
||||||
import org.apache.http.conn.BasicManagedEntity;
|
import org.apache.http.conn.BasicManagedEntity;
|
||||||
import org.apache.http.conn.ClientConnectionManager;
|
import org.apache.http.conn.ClientConnectionManager;
|
||||||
import org.apache.http.conn.ClientConnectionRequest;
|
import org.apache.http.conn.ClientConnectionRequest;
|
||||||
|
@ -241,13 +241,13 @@ public class DefaultClientRequestDirector
|
||||||
// Make sure the request URI is absolute
|
// Make sure the request URI is absolute
|
||||||
if (!uri.isAbsolute()) {
|
if (!uri.isAbsolute()) {
|
||||||
HttpHost target = route.getTargetHost();
|
HttpHost target = route.getTargetHost();
|
||||||
uri = URLUtils.rewriteURI(uri, target);
|
uri = URIUtils.rewriteURI(uri, target);
|
||||||
request.setURI(uri);
|
request.setURI(uri);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make sure the request URI is relative
|
// Make sure the request URI is relative
|
||||||
if (uri.isAbsolute()) {
|
if (uri.isAbsolute()) {
|
||||||
uri = URLUtils.rewriteURI(uri, null);
|
uri = URIUtils.rewriteURI(uri, null);
|
||||||
request.setURI(uri);
|
request.setURI(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.http.ProtocolException;
|
||||||
import org.apache.http.client.CircularRedirectException;
|
import org.apache.http.client.CircularRedirectException;
|
||||||
import org.apache.http.client.RedirectHandler;
|
import org.apache.http.client.RedirectHandler;
|
||||||
import org.apache.http.client.params.ClientPNames;
|
import org.apache.http.client.params.ClientPNames;
|
||||||
import org.apache.http.client.utils.URLUtils;
|
import org.apache.http.client.utils.URIUtils;
|
||||||
import org.apache.http.params.HttpParams;
|
import org.apache.http.params.HttpParams;
|
||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
import org.apache.http.protocol.ExecutionContext;
|
import org.apache.http.protocol.ExecutionContext;
|
||||||
|
@ -137,8 +137,8 @@ public class DefaultRedirectHandler implements RedirectHandler {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URI requestURI = new URI(request.getRequestLine().getUri());
|
URI requestURI = new URI(request.getRequestLine().getUri());
|
||||||
URI absoluteRequestURI = URLUtils.rewriteURI(requestURI, target, true);
|
URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, true);
|
||||||
uri = URLUtils.resolve(absoluteRequestURI, uri);
|
uri = URIUtils.resolve(absoluteRequestURI, uri);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
throw new ProtocolException(ex.getMessage(), ex);
|
throw new ProtocolException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class DefaultRedirectHandler implements RedirectHandler {
|
||||||
uri.getHost(),
|
uri.getHost(),
|
||||||
uri.getPort(),
|
uri.getPort(),
|
||||||
uri.getScheme());
|
uri.getScheme());
|
||||||
redirectURI = URLUtils.rewriteURI(uri, target, true);
|
redirectURI = URIUtils.rewriteURI(uri, target, true);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
throw new ProtocolException(ex.getMessage(), ex);
|
throw new ProtocolException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue