Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CF9B0988C for ; Wed, 13 Jun 2012 07:57:09 +0000 (UTC) Received: (qmail 89897 invoked by uid 500); 13 Jun 2012 07:57:09 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 89774 invoked by uid 500); 13 Jun 2012 07:57:06 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 89722 invoked by uid 99); 13 Jun 2012 07:57:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2012 07:57:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2012 07:57:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A2E552388980 for ; Wed, 13 Jun 2012 07:56:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Wed, 13 Jun 2012 07:56:35 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120613075635.A2E552388980@eris.apache.org> 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; }