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 DE519C32E for ; Fri, 22 Jun 2012 11:05:33 +0000 (UTC) Received: (qmail 468 invoked by uid 500); 22 Jun 2012 11:05:33 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 437 invoked by uid 500); 22 Jun 2012 11:05:33 -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 427 invoked by uid 99); 22 Jun 2012 11:05:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jun 2012 11:05:33 +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; Fri, 22 Jun 2012 11:05:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0A473238890B for ; Fri, 22 Jun 2012 11:05:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1352845 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java Date: Fri, 22 Jun 2012 11:05:11 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120622110512.0A473238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Fri Jun 22 11:05:10 2012 New Revision: 1352845 URL: http://svn.apache.org/viewvc?rev=1352845&view=rev Log: HTTPCLIENT-1209: Redirect URIs are now normalized Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1352845&r1=1352844&r2=1352845&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original) +++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Fri Jun 22 11:05:10 2012 @@ -1,5 +1,9 @@ Changes since 4.2 ------------------- + +* [HTTPCLIENT-1209] Redirect URIs are now normalized. + Contributed by Oleg Kalnichevski + * [HTTPCLIENT-1202] ResponseCachingPolicy should honor explicit cache-control directives for other status codes Contributed by Jon Moore Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java?rev=1352845&r1=1352844&r2=1352845&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java Fri Jun 22 11:05:10 2012 @@ -184,7 +184,7 @@ public class DefaultRedirectStrategy imp */ protected URI createLocationURI(final String location) throws ProtocolException { try { - return new URI(location); + return new URI(location).normalize(); } catch (URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java?rev=1352845&r1=1352844&r2=1352845&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java Fri Jun 22 11:05:10 2012 @@ -232,6 +232,19 @@ public class TestDefaultRedirectStrategy Assert.assertEquals(URI.create("http://localhost/stuff"), uri); } + @Test + public void testGetLocationUriNormalized() throws Exception { + DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + HttpContext context = new BasicHttpContext(); + context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, new HttpHost("localhost")); + HttpGet httpget = new HttpGet("http://localhost/"); + HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, + HttpStatus.SC_MOVED_TEMPORARILY, "Redirect"); + response.addHeader("Location", "http://localhost/././stuff/../morestuff"); + URI uri = redirectStrategy.getLocationURI(httpget, response, context); + Assert.assertEquals(URI.create("http://localhost/morestuff"), uri); + } + @Test(expected=ProtocolException.class) public void testGetLocationUriRelativeLocationNotAllowed() throws Exception { DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();