From e8923010c75b47b4b815f711e0ec6307f7b14859 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 5 Apr 2008 10:54:12 +0000 Subject: [PATCH] HTTPCLIENT-746: Refactored URLUtils into URLEncodedUtils and URIUtils Contributed by Stojce Dimski Reviewed by Oleg Kalnichevski git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@645072 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/client/utils/{URLUtils.java => URIUtils.java} | 10 +++++----- .../http/impl/client/DefaultClientRequestDirector.java | 6 +++--- .../http/impl/client/DefaultRedirectHandler.java | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) rename module-client/src/main/java/org/apache/http/client/utils/{URLUtils.java => URIUtils.java} (96%) diff --git a/module-client/src/main/java/org/apache/http/client/utils/URLUtils.java b/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java similarity index 96% rename from module-client/src/main/java/org/apache/http/client/utils/URLUtils.java rename to module-client/src/main/java/org/apache/http/client/utils/URIUtils.java index 51f33beb5..445a23586 100644 --- a/module-client/src/main/java/org/apache/http/client/utils/URLUtils.java +++ b/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java @@ -34,7 +34,7 @@ import java.net.URISyntaxException; import org.apache.http.HttpHost; -public class URLUtils { +public class URIUtils { public static URI createURI( final String scheme, @@ -81,7 +81,7 @@ public class URLUtils { throw new IllegalArgumentException("URI may nor be null"); } if (target != null) { - return URLUtils.createURI( + return URIUtils.createURI( target.getSchemeName(), target.getHostName(), target.getPort(), @@ -89,7 +89,7 @@ public class URLUtils { uri.getRawQuery(), dropFragment ? null : uri.getRawFragment()); } else { - return URLUtils.createURI( + return URIUtils.createURI( null, null, -1, @@ -114,7 +114,7 @@ public class URLUtils { * @return the resulting URI */ 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. */ - private URLUtils() { + private URIUtils() { } } diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java index 67bf6d1bb..579614e3b 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java +++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java @@ -67,7 +67,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.params.ClientPNames; import org.apache.http.client.params.HttpClientParams; 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.ClientConnectionManager; import org.apache.http.conn.ClientConnectionRequest; @@ -241,13 +241,13 @@ public class DefaultClientRequestDirector // Make sure the request URI is absolute if (!uri.isAbsolute()) { HttpHost target = route.getTargetHost(); - uri = URLUtils.rewriteURI(uri, target); + uri = URIUtils.rewriteURI(uri, target); request.setURI(uri); } } else { // Make sure the request URI is relative if (uri.isAbsolute()) { - uri = URLUtils.rewriteURI(uri, null); + uri = URIUtils.rewriteURI(uri, null); request.setURI(uri); } } diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java index e14f308e1..5fcb59ee3 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java +++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java @@ -45,7 +45,7 @@ import org.apache.http.ProtocolException; import org.apache.http.client.CircularRedirectException; import org.apache.http.client.RedirectHandler; 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.protocol.HttpContext; import org.apache.http.protocol.ExecutionContext; @@ -137,8 +137,8 @@ public class DefaultRedirectHandler implements RedirectHandler { try { URI requestURI = new URI(request.getRequestLine().getUri()); - URI absoluteRequestURI = URLUtils.rewriteURI(requestURI, target, true); - uri = URLUtils.resolve(absoluteRequestURI, uri); + URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, true); + uri = URIUtils.resolve(absoluteRequestURI, uri); } catch (URISyntaxException ex) { throw new ProtocolException(ex.getMessage(), ex); } @@ -161,7 +161,7 @@ public class DefaultRedirectHandler implements RedirectHandler { uri.getHost(), uri.getPort(), uri.getScheme()); - redirectURI = URLUtils.rewriteURI(uri, target, true); + redirectURI = URIUtils.rewriteURI(uri, target, true); } catch (URISyntaxException ex) { throw new ProtocolException(ex.getMessage(), ex); }