mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-18 16:07:11 +00:00
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
This commit is contained in:
parent
61f45b5c48
commit
73e6ca8bb8
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.http.HttpHost;
|
|
||||||
import org.apache.http.annotation.Immutable;
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
import org.apache.http.util.LangUtils;
|
import org.apache.http.util.LangUtils;
|
||||||
@ -110,20 +109,6 @@ public AuthScope(final String host, int port,
|
|||||||
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
|
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
|
/** Creates a new credentials scope for the given
|
||||||
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and any
|
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and any
|
||||||
* authentication scheme.
|
* authentication scheme.
|
||||||
|
@ -112,7 +112,8 @@ private void doPreemptiveAuth(
|
|||||||
this.log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host);
|
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);
|
Credentials creds = credsProvider.getCredentials(authScope);
|
||||||
|
|
||||||
if (creds != null) {
|
if (creds != null) {
|
||||||
|
@ -142,10 +142,7 @@ public int getRetryCount() {
|
|||||||
return retryCount;
|
return retryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private boolean handleAsIdempotent(final HttpRequest request) {
|
||||||
* @since 4.2
|
|
||||||
*/
|
|
||||||
protected boolean handleAsIdempotent(final HttpRequest request) {
|
|
||||||
return !(request instanceof HttpEntityEnclosingRequest);
|
return !(request instanceof HttpEntityEnclosingRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
* <http://www.apache.org/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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<String, Boolean> idempotentMethods;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor
|
|
||||||
*/
|
|
||||||
public StandardHttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled) {
|
|
||||||
super(retryCount, requestSentRetryEnabled);
|
|
||||||
this.idempotentMethods = new ConcurrentHashMap<String, Boolean>();
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -68,8 +68,8 @@ public void setUp() {
|
|||||||
this.credProvider = new BasicCredentialsProvider();
|
this.credProvider = new BasicCredentialsProvider();
|
||||||
this.creds1 = new UsernamePasswordCredentials("user1", "secret1");
|
this.creds1 = new UsernamePasswordCredentials("user1", "secret1");
|
||||||
this.creds2 = new UsernamePasswordCredentials("user2", "secret2");
|
this.creds2 = new UsernamePasswordCredentials("user2", "secret2");
|
||||||
this.authscope1 = new AuthScope(this.target);
|
this.authscope1 = new AuthScope(this.target.getHostName(), this.target.getPort());
|
||||||
this.authscope2 = new AuthScope(this.proxy);
|
this.authscope2 = new AuthScope(this.proxy.getHostName(), this.proxy.getPort());
|
||||||
this.authscheme1 = new BasicScheme();
|
this.authscheme1 = new BasicScheme();
|
||||||
this.authscheme2 = new BasicScheme();
|
this.authscheme2 = new BasicScheme();
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ public void setUp() throws Exception {
|
|||||||
|
|
||||||
this.creds1 = new UsernamePasswordCredentials("user1", "secret1");
|
this.creds1 = new UsernamePasswordCredentials("user1", "secret1");
|
||||||
this.creds2 = new UsernamePasswordCredentials("user2", "secret2");
|
this.creds2 = new UsernamePasswordCredentials("user2", "secret2");
|
||||||
this.authscope1 = new AuthScope(this.target);
|
this.authscope1 = new AuthScope(this.target.getHostName(), this.target.getPort());
|
||||||
this.authscope2 = new AuthScope(this.proxy);
|
this.authscope2 = new AuthScope(this.proxy.getHostName(), this.proxy.getPort());
|
||||||
this.authscheme1 = new BasicScheme();
|
this.authscheme1 = new BasicScheme();
|
||||||
this.authscheme2 = new BasicScheme();
|
this.authscheme2 = new BasicScheme();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user