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 C008C18092 for ; Sun, 21 Jun 2015 10:44:32 +0000 (UTC) Received: (qmail 80561 invoked by uid 500); 21 Jun 2015 10:44:32 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 80526 invoked by uid 500); 21 Jun 2015 10:44:32 -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 80516 invoked by uid 99); 21 Jun 2015 10:44:32 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jun 2015 10:44:32 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id ED9AEAC094D for ; Sun, 21 Jun 2015 10:44:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1686699 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/config/ main/java/org/apache/http/impl/client/ test/java/org/apache/http/client/config/ test/java/org/apache/http/impl/client/ test/java/org/apa... Date: Sun, 21 Jun 2015 10:44:31 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150621104431.ED9AEAC094D@hades.apache.org> Author: olegk Date: Sun Jun 21 10:44:31 2015 New Revision: 1686699 URL: http://svn.apache.org/r1686699 Log: RFC 7231: removed restriction on the use of relative URIs in Location header Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java?rev=1686699&r1=1686698&r2=1686699&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java Sun Jun 21 10:44:31 2015 @@ -48,7 +48,6 @@ public class RequestConfig implements Cl private final InetAddress localAddress; private final String cookieSpec; private final boolean redirectsEnabled; - private final boolean relativeRedirectsAllowed; private final boolean circularRedirectsAllowed; private final int maxRedirects; private final boolean authenticationEnabled; @@ -89,7 +88,6 @@ public class RequestConfig implements Cl this.localAddress = localAddress; this.cookieSpec = cookieSpec; this.redirectsEnabled = redirectsEnabled; - this.relativeRedirectsAllowed = relativeRedirectsAllowed; this.circularRedirectsAllowed = circularRedirectsAllowed; this.maxRedirects = maxRedirects; this.authenticationEnabled = authenticationEnabled; @@ -174,17 +172,6 @@ public class RequestConfig implements Cl } /** - * Determines whether relative redirects should be rejected. HTTP specification - * requires the location value be an absolute URI. - *

- * Default: {@code true} - *

- */ - public boolean isRelativeRedirectsAllowed() { - return relativeRedirectsAllowed; - } - - /** * Determines whether circular redirects (redirects to the same location) should * be allowed. The HTTP spec is not sufficiently clear whether circular redirects * are permitted, therefore optionally they can be enabled @@ -312,7 +299,6 @@ public class RequestConfig implements Cl builder.append(", localAddress=").append(localAddress); builder.append(", cookieSpec=").append(cookieSpec); builder.append(", redirectsEnabled=").append(redirectsEnabled); - builder.append(", relativeRedirectsAllowed=").append(relativeRedirectsAllowed); builder.append(", maxRedirects=").append(maxRedirects); builder.append(", circularRedirectsAllowed=").append(circularRedirectsAllowed); builder.append(", authenticationEnabled=").append(authenticationEnabled); @@ -337,7 +323,6 @@ public class RequestConfig implements Cl .setLocalAddress(config.getLocalAddress()) .setCookieSpec(config.getCookieSpec()) .setRedirectsEnabled(config.isRedirectsEnabled()) - .setRelativeRedirectsAllowed(config.isRelativeRedirectsAllowed()) .setCircularRedirectsAllowed(config.isCircularRedirectsAllowed()) .setMaxRedirects(config.getMaxRedirects()) .setAuthenticationEnabled(config.isAuthenticationEnabled()) 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=1686699&r1=1686698&r2=1686699&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 Sun Jun 21 10:44:31 2015 @@ -123,16 +123,9 @@ public class DefaultRedirectStrategy imp final RequestConfig config = clientContext.getRequestConfig(); URI uri = createLocationURI(location); - - // rfc2616 demands the location value be a complete URI - // Location = "Location" ":" absoluteURI try { if (!uri.isAbsolute()) { - if (!config.isRelativeRedirectsAllowed()) { - throw new ProtocolException("Relative redirect location '" - + uri + "' not allowed"); - } - // Adjust location URI + // Resolve location URI final HttpHost target = clientContext.getTargetHost(); Asserts.notNull(target, "Target host"); final URI requestURI = new URI(request.getRequestLine().getUri()); Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java?rev=1686699&r1=1686698&r2=1686699&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java Sun Jun 21 10:44:31 2015 @@ -51,7 +51,6 @@ public class TestRequestConfig { Assert.assertEquals(false, config.isExpectContinueEnabled()); Assert.assertEquals(true, config.isAuthenticationEnabled()); Assert.assertEquals(true, config.isRedirectsEnabled()); - Assert.assertEquals(true, config.isRelativeRedirectsAllowed()); Assert.assertEquals(false, config.isCircularRedirectsAllowed()); Assert.assertEquals(50, config.getMaxRedirects()); Assert.assertEquals(null, config.getCookieSpec()); @@ -88,7 +87,6 @@ public class TestRequestConfig { Assert.assertEquals(true, config.isExpectContinueEnabled()); Assert.assertEquals(false, config.isAuthenticationEnabled()); Assert.assertEquals(false, config.isRedirectsEnabled()); - Assert.assertEquals(false, config.isRelativeRedirectsAllowed()); Assert.assertEquals(true, config.isCircularRedirectsAllowed()); Assert.assertEquals(100, config.getMaxRedirects()); Assert.assertEquals(CookieSpecs.STANDARD, config.getCookieSpec()); 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=1686699&r1=1686698&r2=1686699&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 Sun Jun 21 10:44:31 2015 @@ -240,21 +240,6 @@ public class TestDefaultRedirectStrategy Assert.assertEquals(URI.create("http://localhost/morestuff"), uri); } - @Test(expected=ProtocolException.class) - public void testGetLocationUriRelativeLocationNotAllowed() throws Exception { - final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); - final HttpClientContext context = HttpClientContext.create(); - context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, new HttpHost("localhost")); - final RequestConfig config = RequestConfig.custom().setRelativeRedirectsAllowed(false).build(); - context.setRequestConfig(config); - - final HttpGet httpget = new HttpGet("http://localhost/"); - final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, - HttpStatus.SC_MOVED_TEMPORARILY, "Redirect"); - response.addHeader("Location", "/stuff"); - redirectStrategy.getLocationURI(httpget, response, context); - } - @Test public void testGetLocationUriAllowCircularRedirects() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java?rev=1686699&r1=1686698&r2=1686699&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java Sun Jun 21 10:44:31 2015 @@ -616,23 +616,6 @@ public class TestRedirects extends Local } @Test(expected=ClientProtocolException.class) - public void testRejectRelativeRedirect() throws Exception { - this.serverBootstrap.registerHandler("*", new RelativeRedirectService()); - - final HttpHost target = start(); - - final RequestConfig config = RequestConfig.custom().setRelativeRedirectsAllowed(false).build(); - final HttpGet httpget = new HttpGet("/oldlocation/"); - httpget.setConfig(config); - try { - this.httpclient.execute(target, httpget); - } catch (final ClientProtocolException e) { - Assert.assertTrue(e.getCause() instanceof ProtocolException); - throw e; - } - } - - @Test(expected=ClientProtocolException.class) public void testRejectBogusRedirectLocation() throws Exception { this.serverBootstrap.registerHandler("*", new BogusRedirectService("xxx://bogus"));