You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/06/13 09:56:35 UTC
svn commit: r1349669 - in /httpcomponents/httpclient/trunk/httpclient/src:
main/java/org/apache/http/client/utils/URIUtils.java
test/java/org/apache/http/client/protocol/TestUriEscapes.java
Author: olegk
Date: Wed Jun 13 07:56:35 2012
New Revision: 1349669
URL: http://svn.apache.org/viewvc?rev=1349669&view=rev
Log:
HTTPCLIENT-1195: URI rewrite methods in URIUtils now use URIBuilder internally
Removed:
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java
Modified:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java?rev=1349669&r1=1349668&r2=1349669&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java Wed Jun 13 07:56:35 2012
@@ -68,7 +68,10 @@ public class URIUtils {
* components violates RFC 2396, or if the authority
* component of the string is present but cannot be parsed
* as a server-based authority
+ *
+ * @deprecated (4.2) use {@link URIBuilder}.
*/
+ @Deprecated
public static URI createURI(
final String scheme,
final String host,
@@ -76,7 +79,6 @@ public class URIUtils {
final String path,
final String query,
final String fragment) throws URISyntaxException {
-
StringBuilder buffer = new StringBuilder();
if (host != null) {
if (scheme != null) {
@@ -129,23 +131,21 @@ public class URIUtils {
if (uri == null) {
throw new IllegalArgumentException("URI may not be null");
}
+ URIBuilder uribuilder = new URIBuilder(uri);
if (target != null) {
- return URIUtils.createURI(
- target.getSchemeName(),
- target.getHostName(),
- target.getPort(),
- normalizePath(uri.getRawPath()),
- uri.getRawQuery(),
- dropFragment ? null : uri.getRawFragment());
+ uribuilder.setScheme(target.getSchemeName());
+ uribuilder.setHost(target.getHostName());
+ uribuilder.setPort(target.getPort());
} else {
- return URIUtils.createURI(
- null,
- null,
- -1,
- normalizePath(uri.getRawPath()),
- uri.getRawQuery(),
- dropFragment ? null : uri.getRawFragment());
+ uribuilder.setScheme(null);
+ uribuilder.setHost(null);
+ uribuilder.setPort(-1);
+ }
+ uribuilder.setPath(normalizePath(uribuilder.getPath()));
+ if (dropFragment) {
+ uribuilder.setFragment(null);
}
+ return uribuilder.build();
}
private static String normalizePath(String path) {
@@ -190,13 +190,7 @@ public class URIUtils {
throw new IllegalArgumentException("URI may not be null");
}
if (uri.getFragment() != null) {
- return URIUtils.createURI(
- uri.getScheme(),
- uri.getHost(),
- uri.getPort(),
- uri.getRawPath(),
- uri.getRawQuery(),
- null);
+ return new URIBuilder(uri).setFragment(null).build();
} else {
return uri;
}