From 73e6ca8bb80119eea448019535bba3c33a6d2e66 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 8 Mar 2011 20:54:13 +0000 Subject: [PATCH] Removed 4.2 methods git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.1.x@1079534 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/http/auth/AuthScope.java | 15 ---- .../client/protocol/RequestAuthCache.java | 3 +- .../DefaultHttpRequestRetryHandler.java | 5 +- .../StandardHttpRequestRetryHandler.java | 81 ------------------- .../client/protocol/TestRequestAuthCache.java | 4 +- .../protocol/TestResponseAuthCache.java | 4 +- 6 files changed, 7 insertions(+), 105 deletions(-) delete mode 100644 httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java index 26e6f7040..f14627cff 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java @@ -28,7 +28,6 @@ package org.apache.http.auth; import java.util.Locale; -import org.apache.http.HttpHost; import org.apache.http.annotation.Immutable; import org.apache.http.util.LangUtils; @@ -110,20 +109,6 @@ public class AuthScope { this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH); } - /** - * @since 4.2 - */ - public AuthScope(final HttpHost host, final String realm, final String schemeName) { - this(host.getHostName(), host.getPort(), realm, schemeName); - } - - /** - * @since 4.2 - */ - public AuthScope(final HttpHost host) { - this(host, ANY_REALM, ANY_SCHEME); - } - /** Creates a new credentials scope for the given * host, port, realm, and any * authentication scheme. diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java index 0602824f6..4693418f7 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java @@ -112,7 +112,8 @@ public class RequestAuthCache implements HttpRequestInterceptor { this.log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host); } - AuthScope authScope = new AuthScope(host, AuthScope.ANY_REALM, schemeName); + AuthScope authScope = new AuthScope(host.getHostName(), host.getPort(), + AuthScope.ANY_REALM, schemeName); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java index e586ba3c1..9cfecc7ed 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java @@ -142,10 +142,7 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { return retryCount; } - /** - * @since 4.2 - */ - protected boolean handleAsIdempotent(final HttpRequest request) { + private boolean handleAsIdempotent(final HttpRequest request) { return !(request instanceof HttpEntityEnclosingRequest); } diff --git a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java deleted file mode 100644 index 0ebac0d23..000000000 --- a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package org.apache.http.impl.client; - -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; -import org.apache.http.client.HttpRequestRetryHandler; - -/** - * A {@link HttpRequestRetryHandler} which assumes that all requested - * HTTP methods which should be idempotent according to RFC-2616 are - * in fact idempotent and can be retried. - * - * According to RFC-2616 section 9.1.2 the idempotent HTTP methods are: - * GET, HEAD, PUT, DELETE, OPTIONS, and TRACE - * - * @since 4.2 - */ -@Immutable -public class StandardHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler { - - private final Map idempotentMethods; - - /** - * Default constructor - */ - public StandardHttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled) { - super(retryCount, requestSentRetryEnabled); - this.idempotentMethods = new ConcurrentHashMap(); - this.idempotentMethods.put("GET", Boolean.TRUE); - this.idempotentMethods.put("HEAD", Boolean.TRUE); - this.idempotentMethods.put("PUT", Boolean.TRUE); - this.idempotentMethods.put("DELETE", Boolean.TRUE); - this.idempotentMethods.put("OPTIONS", Boolean.TRUE); - this.idempotentMethods.put("TRACE", Boolean.TRUE); - } - - /** - * Default constructor - */ - public StandardHttpRequestRetryHandler() { - this(3, false); - } - - @Override - protected boolean handleAsIdempotent(final HttpRequest request) { - String method = request.getRequestLine().getMethod().toUpperCase(Locale.US); - Boolean b = this.idempotentMethods.get(method); - return b != null && b.booleanValue(); - } - -} diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java index 6f93890a1..6f6742f0c 100644 --- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java +++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java @@ -68,8 +68,8 @@ public class TestRequestAuthCache { this.credProvider = new BasicCredentialsProvider(); this.creds1 = new UsernamePasswordCredentials("user1", "secret1"); this.creds2 = new UsernamePasswordCredentials("user2", "secret2"); - this.authscope1 = new AuthScope(this.target); - this.authscope2 = new AuthScope(this.proxy); + this.authscope1 = new AuthScope(this.target.getHostName(), this.target.getPort()); + this.authscope2 = new AuthScope(this.proxy.getHostName(), this.proxy.getPort()); this.authscheme1 = new BasicScheme(); this.authscheme2 = new BasicScheme(); diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java index 6ed4e301e..d8edf3518 100644 --- a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java +++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java @@ -68,8 +68,8 @@ public class TestResponseAuthCache { this.creds1 = new UsernamePasswordCredentials("user1", "secret1"); this.creds2 = new UsernamePasswordCredentials("user2", "secret2"); - this.authscope1 = new AuthScope(this.target); - this.authscope2 = new AuthScope(this.proxy); + this.authscope1 = new AuthScope(this.target.getHostName(), this.target.getPort()); + this.authscope2 = new AuthScope(this.proxy.getHostName(), this.proxy.getPort()); this.authscheme1 = new BasicScheme(); this.authscheme2 = new BasicScheme();