You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/09/02 15:28:08 UTC
[08/17] httpcomponents-client git commit: Moved classes and renamed
packages (no functional changes)
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProtocolExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProtocolExec.java
deleted file mode 100644
index 0d230d1..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProtocolExec.java
+++ /dev/null
@@ -1,249 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
-
-import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.StandardMethods;
-import org.apache.hc.client5.http.auth.AuthExchange;
-import org.apache.hc.client5.http.auth.ChallengeType;
-import org.apache.hc.client5.http.auth.CredentialsProvider;
-import org.apache.hc.client5.http.auth.CredentialsStore;
-import org.apache.hc.client5.http.impl.AuthSupport;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.client5.http.impl.auth.HttpAuthenticator;
-import org.apache.hc.client5.http.protocol.AuthenticationStrategy;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.protocol.NonRepeatableRequestException;
-import org.apache.hc.client5.http.sync.ExecChain;
-import org.apache.hc.client5.http.sync.ExecChainHandler;
-import org.apache.hc.client5.http.sync.ExecRuntime;
-import org.apache.hc.client5.http.utils.URIUtils;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHeaders;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.ProtocolException;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.protocol.HttpCoreContext;
-import org.apache.hc.core5.http.protocol.HttpProcessor;
-import org.apache.hc.core5.net.URIAuthority;
-import org.apache.hc.core5.util.Args;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * Request executor in the request execution chain that is responsible
- * for implementation of HTTP specification requirements.
- * <p>
- * Further responsibilities such as communication with the opposite
- * endpoint is delegated to the next executor in the request execution
- * chain.
- * </p>
- *
- * @since 4.3
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-final class ProtocolExec implements ExecChainHandler {
-
- private final Logger log = LogManager.getLogger(getClass());
-
- private final HttpProcessor httpProcessor;
- private final AuthenticationStrategy targetAuthStrategy;
- private final AuthenticationStrategy proxyAuthStrategy;
- private final HttpAuthenticator authenticator;
-
- public ProtocolExec(
- final HttpProcessor httpProcessor,
- final AuthenticationStrategy targetAuthStrategy,
- final AuthenticationStrategy proxyAuthStrategy) {
- this.httpProcessor = Args.notNull(httpProcessor, "HTTP protocol processor");
- this.targetAuthStrategy = Args.notNull(targetAuthStrategy, "Target authentication strategy");
- this.proxyAuthStrategy = Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
- this.authenticator = new HttpAuthenticator();
- }
-
- @Override
- public ClassicHttpResponse execute(
- final ClassicHttpRequest request,
- final ExecChain.Scope scope,
- final ExecChain chain) throws IOException, HttpException {
- Args.notNull(request, "HTTP request");
- Args.notNull(scope, "Scope");
-
- final HttpRoute route = scope.route;
- final HttpClientContext context = scope.clientContext;
- final ExecRuntime execRuntime = scope.execRuntime;
-
- try {
- final HttpHost target = route.getTargetHost();
- final HttpHost proxy = route.getProxyHost();
- if (proxy != null && !route.isTunnelled()) {
- try {
- URI uri = request.getUri();
- if (!uri.isAbsolute()) {
- uri = URIUtils.rewriteURI(uri, target, true);
- } else {
- uri = URIUtils.rewriteURI(uri);
- }
- request.setPath(uri.toASCIIString());
- } catch (final URISyntaxException ex) {
- throw new ProtocolException("Invalid request URI: " + request.getRequestUri(), ex);
- }
- }
-
- final URIAuthority authority = request.getAuthority();
- if (authority != null) {
- final CredentialsProvider credsProvider = context.getCredentialsProvider();
- if (credsProvider instanceof CredentialsStore) {
- AuthSupport.extractFromAuthority(authority, (CredentialsStore) credsProvider);
- }
- }
-
- final AuthExchange targetAuthExchange = context.getAuthExchange(target);
- final AuthExchange proxyAuthExchange = proxy != null ? context.getAuthExchange(proxy) : new AuthExchange();
-
- for (int execCount = 1;; execCount++) {
-
- if (execCount > 1) {
- final HttpEntity entity = request.getEntity();
- if (entity != null && !entity.isRepeatable()) {
- throw new NonRepeatableRequestException("Cannot retry request " +
- "with a non-repeatable request entity.");
- }
- }
-
- // Run request protocol interceptors
- context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
- context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
-
- httpProcessor.process(request, request.getEntity(), context);
-
- if (!request.containsHeader(HttpHeaders.AUTHORIZATION)) {
- if (log.isDebugEnabled()) {
- log.debug("Target auth state: " + targetAuthExchange.getState());
- }
- authenticator.addAuthResponse(target, ChallengeType.TARGET, request, targetAuthExchange, context);
- }
- if (!request.containsHeader(HttpHeaders.PROXY_AUTHORIZATION) && !route.isTunnelled()) {
- if (log.isDebugEnabled()) {
- log.debug("Proxy auth state: " + proxyAuthExchange.getState());
- }
- authenticator.addAuthResponse(proxy, ChallengeType.PROXY, request, proxyAuthExchange, context);
- }
-
- final ClassicHttpResponse response = chain.proceed(request, scope);
-
- context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
- httpProcessor.process(response, response.getEntity(), context);
-
- if (request.getMethod().equalsIgnoreCase(StandardMethods.TRACE.name())) {
- // Do not perform authentication for TRACE request
- return response;
- }
-
- if (needAuthentication(targetAuthExchange, proxyAuthExchange, route, request, response, context)) {
- // Make sure the response body is fully consumed, if present
- final HttpEntity entity = response.getEntity();
- if (execRuntime.isConnectionReusable()) {
- EntityUtils.consume(entity);
- } else {
- execRuntime.disconnect();
- if (proxyAuthExchange.getState() == AuthExchange.State.SUCCESS
- && proxyAuthExchange.getAuthScheme() != null
- && proxyAuthExchange.getAuthScheme().isConnectionBased()) {
- log.debug("Resetting proxy auth state");
- proxyAuthExchange.reset();
- }
- if (targetAuthExchange.getState() == AuthExchange.State.SUCCESS
- && targetAuthExchange.getAuthScheme() != null
- && targetAuthExchange.getAuthScheme().isConnectionBased()) {
- log.debug("Resetting target auth state");
- targetAuthExchange.reset();
- }
- }
- // Reset request headers
- final ClassicHttpRequest original = scope.originalRequest;
- request.setHeaders();
- for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
- request.addHeader(it.next());
- }
- } else {
- return response;
- }
- }
- } catch (final RuntimeException | HttpException | IOException ex) {
- execRuntime.discardConnection();
- throw ex;
- }
- }
-
- private boolean needAuthentication(
- final AuthExchange targetAuthExchange,
- final AuthExchange proxyAuthExchange,
- final HttpRoute route,
- final ClassicHttpRequest request,
- final HttpResponse response,
- final HttpClientContext context) {
- final RequestConfig config = context.getRequestConfig();
- if (config.isAuthenticationEnabled()) {
- final HttpHost target = AuthSupport.resolveAuthTarget(request, route);
- final boolean targetAuthRequested = authenticator.isChallenged(
- target, ChallengeType.TARGET, response, targetAuthExchange, context);
-
- HttpHost proxy = route.getProxyHost();
- // if proxy is not set use target host instead
- if (proxy == null) {
- proxy = route.getTargetHost();
- }
- final boolean proxyAuthRequested = authenticator.isChallenged(
- proxy, ChallengeType.PROXY, response, proxyAuthExchange, context);
-
- if (targetAuthRequested) {
- return authenticator.prepareAuthResponse(target, ChallengeType.TARGET, response,
- targetAuthStrategy, targetAuthExchange, context);
- }
- if (proxyAuthRequested) {
- return authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
- proxyAuthStrategy, proxyAuthExchange, context);
- }
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProxyClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProxyClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProxyClient.java
deleted file mode 100644
index c7d2e63..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProxyClient.java
+++ /dev/null
@@ -1,217 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.RouteInfo.LayerType;
-import org.apache.hc.client5.http.RouteInfo.TunnelType;
-import org.apache.hc.client5.http.SystemDefaultDnsResolver;
-import org.apache.hc.client5.http.auth.AuthExchange;
-import org.apache.hc.client5.http.auth.AuthSchemeProvider;
-import org.apache.hc.client5.http.auth.AuthScope;
-import org.apache.hc.client5.http.auth.ChallengeType;
-import org.apache.hc.client5.http.auth.Credentials;
-import org.apache.hc.client5.http.config.AuthSchemes;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
-import org.apache.hc.client5.http.impl.auth.DigestSchemeFactory;
-import org.apache.hc.client5.http.impl.auth.HttpAuthenticator;
-import org.apache.hc.client5.http.impl.auth.KerberosSchemeFactory;
-import org.apache.hc.client5.http.impl.auth.NTLMSchemeFactory;
-import org.apache.hc.client5.http.impl.auth.SPNegoSchemeFactory;
-import org.apache.hc.client5.http.impl.io.ManagedHttpClientConnectionFactory;
-import org.apache.hc.client5.http.impl.protocol.DefaultAuthenticationStrategy;
-import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
-import org.apache.hc.client5.http.protocol.AuthenticationStrategy;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.protocol.RequestClientConnControl;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.ConnectionReuseStrategy;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHeaders;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.config.CharCodingConfig;
-import org.apache.hc.core5.http.config.H1Config;
-import org.apache.hc.core5.http.config.Lookup;
-import org.apache.hc.core5.http.config.RegistryBuilder;
-import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
-import org.apache.hc.core5.http.io.HttpConnectionFactory;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
-import org.apache.hc.core5.http.message.StatusLine;
-import org.apache.hc.core5.http.protocol.BasicHttpContext;
-import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
-import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.http.protocol.HttpCoreContext;
-import org.apache.hc.core5.http.protocol.HttpProcessor;
-import org.apache.hc.core5.http.protocol.RequestTargetHost;
-import org.apache.hc.core5.http.protocol.RequestUserAgent;
-import org.apache.hc.core5.util.Args;
-
-/**
- * ProxyClient can be used to establish a tunnel via an HTTP proxy.
- */
-public class ProxyClient {
-
- private final HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
- private final RequestConfig requestConfig;
- private final HttpProcessor httpProcessor;
- private final HttpRequestExecutor requestExec;
- private final AuthenticationStrategy proxyAuthStrategy;
- private final HttpAuthenticator authenticator;
- private final AuthExchange proxyAuthExchange;
- private final Lookup<AuthSchemeProvider> authSchemeRegistry;
- private final ConnectionReuseStrategy reuseStrategy;
-
- /**
- * @since 5.0
- */
- public ProxyClient(
- final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
- final H1Config h1Config,
- final CharCodingConfig charCodingConfig,
- final RequestConfig requestConfig) {
- super();
- this.connFactory = connFactory != null ? connFactory : new ManagedHttpClientConnectionFactory(h1Config, charCodingConfig, null, null);
- this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT;
- this.httpProcessor = new DefaultHttpProcessor(
- new RequestTargetHost(), new RequestClientConnControl(), new RequestUserAgent());
- this.requestExec = new HttpRequestExecutor();
- this.proxyAuthStrategy = new DefaultAuthenticationStrategy();
- this.authenticator = new HttpAuthenticator();
- this.proxyAuthExchange = new AuthExchange();
- this.authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
- .register(AuthSchemes.BASIC, new BasicSchemeFactory())
- .register(AuthSchemes.DIGEST, new DigestSchemeFactory())
- .register(AuthSchemes.NTLM, new NTLMSchemeFactory())
- .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(SystemDefaultDnsResolver.INSTANCE, true, true))
- .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory(SystemDefaultDnsResolver.INSTANCE, true, true))
- .build();
- this.reuseStrategy = new DefaultConnectionReuseStrategy();
- }
-
- /**
- * @since 4.3
- */
- public ProxyClient(final RequestConfig requestConfig) {
- this(null, null, null, requestConfig);
- }
-
- public ProxyClient() {
- this(null, null, null, null);
- }
-
- public Socket tunnel(
- final HttpHost proxy,
- final HttpHost target,
- final Credentials credentials) throws IOException, HttpException {
- Args.notNull(proxy, "Proxy host");
- Args.notNull(target, "Target host");
- Args.notNull(credentials, "Credentials");
- HttpHost host = target;
- if (host.getPort() <= 0) {
- host = new HttpHost(host.getHostName(), 80, host.getSchemeName());
- }
- final HttpRoute route = new HttpRoute(
- host,
- this.requestConfig.getLocalAddress(),
- proxy, false, TunnelType.TUNNELLED, LayerType.PLAIN);
-
- final ManagedHttpClientConnection conn = this.connFactory.createConnection(null);
- final HttpContext context = new BasicHttpContext();
- ClassicHttpResponse response;
-
- final ClassicHttpRequest connect = new BasicClassicHttpRequest("CONNECT", host.toHostString());
-
- final BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(new AuthScope(proxy), credentials);
-
- // Populate the execution context
- context.setAttribute(HttpCoreContext.HTTP_REQUEST, connect);
- context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
- context.setAttribute(HttpClientContext.CREDS_PROVIDER, credsProvider);
- context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
- context.setAttribute(HttpClientContext.REQUEST_CONFIG, this.requestConfig);
-
- this.requestExec.preProcess(connect, this.httpProcessor, context);
-
- for (;;) {
- if (!conn.isOpen()) {
- final Socket socket = new Socket(proxy.getHostName(), proxy.getPort());
- conn.bind(socket);
- }
-
- this.authenticator.addAuthResponse(proxy, ChallengeType.PROXY, connect, this.proxyAuthExchange, context);
-
- response = this.requestExec.execute(connect, conn, context);
-
- final int status = response.getCode();
- if (status < 200) {
- throw new HttpException("Unexpected response to CONNECT request: " + response);
- }
- if (this.authenticator.isChallenged(proxy, ChallengeType.PROXY, response, this.proxyAuthExchange, context)) {
- if (this.authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
- this.proxyAuthStrategy, this.proxyAuthExchange, context)) {
- // Retry request
- if (this.reuseStrategy.keepAlive(connect, response, context)) {
- // Consume response content
- final HttpEntity entity = response.getEntity();
- EntityUtils.consume(entity);
- } else {
- conn.close();
- }
- // discard previous auth header
- connect.removeHeaders(HttpHeaders.PROXY_AUTHORIZATION);
- } else {
- break;
- }
- } else {
- break;
- }
- }
-
- final int status = response.getCode();
-
- if (status > 299) {
-
- // Buffer response content
- final HttpEntity entity = response.getEntity();
- final String responseMessage = entity != null ? EntityUtils.toString(entity) : null;
- conn.close();
- throw new TunnelRefusedException("CONNECT refused by proxy: " + new StatusLine(response), responseMessage);
- }
- return conn.getSocket();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RedirectExec.java
deleted file mode 100644
index d666c01..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RedirectExec.java
+++ /dev/null
@@ -1,197 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-
-import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.StandardMethods;
-import org.apache.hc.client5.http.auth.AuthExchange;
-import org.apache.hc.client5.http.auth.AuthScheme;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.protocol.RedirectException;
-import org.apache.hc.client5.http.protocol.RedirectStrategy;
-import org.apache.hc.client5.http.routing.HttpRoutePlanner;
-import org.apache.hc.client5.http.sync.ExecChain;
-import org.apache.hc.client5.http.sync.ExecChainHandler;
-import org.apache.hc.client5.http.sync.methods.HttpGet;
-import org.apache.hc.client5.http.sync.methods.RequestBuilder;
-import org.apache.hc.client5.http.utils.URIUtils;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.ProtocolException;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.util.Args;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * Request executor in the request execution chain that is responsible
- * for handling of request redirects.
- * <p>
- * Further responsibilities such as communication with the opposite
- * endpoint is delegated to the next executor in the request execution
- * chain.
- * </p>
- *
- * @since 4.3
- */
-@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
-final class RedirectExec implements ExecChainHandler {
-
- private final Logger log = LogManager.getLogger(getClass());
-
- private final RedirectStrategy redirectStrategy;
- private final HttpRoutePlanner routePlanner;
-
- public RedirectExec(
- final HttpRoutePlanner routePlanner,
- final RedirectStrategy redirectStrategy) {
- super();
- Args.notNull(routePlanner, "HTTP route planner");
- Args.notNull(redirectStrategy, "HTTP redirect strategy");
- this.routePlanner = routePlanner;
- this.redirectStrategy = redirectStrategy;
- }
-
- @Override
- public ClassicHttpResponse execute(
- final ClassicHttpRequest request,
- final ExecChain.Scope scope,
- final ExecChain chain) throws IOException, HttpException {
- Args.notNull(request, "HTTP request");
- Args.notNull(scope, "Scope");
-
- final HttpClientContext context = scope.clientContext;
-
- final List<URI> redirectLocations = context.getRedirectLocations();
- if (redirectLocations != null) {
- redirectLocations.clear();
- }
-
- final RequestConfig config = context.getRequestConfig();
- final int maxRedirects = config.getMaxRedirects() > 0 ? config.getMaxRedirects() : 50;
- ClassicHttpRequest currentRequest = request;
- ExecChain.Scope currentScope = scope;
- for (int redirectCount = 0;;) {
- final ClassicHttpResponse response = chain.proceed(currentRequest, currentScope);
- try {
- if (config.isRedirectsEnabled() && this.redirectStrategy.isRedirected(request, response, context)) {
-
- if (redirectCount >= maxRedirects) {
- throw new RedirectException("Maximum redirects ("+ maxRedirects + ") exceeded");
- }
- redirectCount++;
-
- final URI redirectUri = this.redirectStrategy.getLocationURI(currentRequest, response, context);
- final ClassicHttpRequest originalRequest = scope.originalRequest;
- ClassicHttpRequest redirect = null;
- final int statusCode = response.getCode();
- switch (statusCode) {
- case HttpStatus.SC_MOVED_PERMANENTLY:
- case HttpStatus.SC_MOVED_TEMPORARILY:
- case HttpStatus.SC_SEE_OTHER:
- if (!StandardMethods.isSafe(request.getMethod())) {
- final HttpGet httpGet = new HttpGet(redirectUri);
- httpGet.setHeaders(originalRequest.getAllHeaders());
- redirect = httpGet;
- } else {
- redirect = null;
- }
- }
- if (redirect == null) {
- redirect = RequestBuilder.copy(originalRequest).setUri(redirectUri).build();
- }
-
- final HttpHost newTarget = URIUtils.extractHost(redirectUri);
- if (newTarget == null) {
- throw new ProtocolException("Redirect URI does not specify a valid host name: " +
- redirectUri);
- }
-
- HttpRoute currentRoute = currentScope.route;
- final boolean crossSiteRedirect = !currentRoute.getTargetHost().equals(newTarget);
- if (crossSiteRedirect) {
-
- final AuthExchange targetAuthExchange = context.getAuthExchange(currentRoute.getTargetHost());
- this.log.debug("Resetting target auth state");
- targetAuthExchange.reset();
- if (currentRoute.getProxyHost() != null) {
- final AuthExchange proxyAuthExchange = context.getAuthExchange(currentRoute.getProxyHost());
- final AuthScheme authScheme = proxyAuthExchange.getAuthScheme();
- if (authScheme != null && authScheme.isConnectionBased()) {
- this.log.debug("Resetting proxy auth state");
- proxyAuthExchange.reset();
- }
- }
- currentRoute = this.routePlanner.determineRoute(newTarget, context);
- currentScope = new ExecChain.Scope(
- currentRoute,
- currentScope.originalRequest,
- currentScope.execRuntime,
- currentScope.clientContext);
- }
-
- if (this.log.isDebugEnabled()) {
- this.log.debug("Redirecting to '" + redirectUri + "' via " + currentRoute);
- }
- currentRequest = redirect;
- RequestEntityProxy.enhance(currentRequest);
-
- EntityUtils.consume(response.getEntity());
- response.close();
- } else {
- return response;
- }
- } catch (final RuntimeException | IOException ex) {
- response.close();
- throw ex;
- } catch (final HttpException ex) {
- // Protocol exception related to a direct.
- // The underlying connection may still be salvaged.
- try {
- EntityUtils.consume(response.getEntity());
- } catch (final IOException ioex) {
- this.log.debug("I/O error while releasing connection", ioex);
- } finally {
- response.close();
- }
- throw ex;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestAbortedException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestAbortedException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestAbortedException.java
deleted file mode 100644
index 4cca93a..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestAbortedException.java
+++ /dev/null
@@ -1,52 +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.hc.client5.http.impl.sync;
-
-import java.io.InterruptedIOException;
-
-/**
- * Signals that the request has been aborted.
- *
- * @since 4.3
- */
-public class RequestAbortedException extends InterruptedIOException {
-
- private static final long serialVersionUID = 4973849966012490112L;
-
- public RequestAbortedException(final String message) {
- super(message);
- }
-
- public RequestAbortedException(final String message, final Throwable cause) {
- super(message);
- if (cause != null) {
- initCause(cause);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestEntityProxy.java
deleted file mode 100644
index 8f837a3..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestEntityProxy.java
+++ /dev/null
@@ -1,142 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.hc.core5.function.Supplier;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpEntity;
-
-/**
- * A Proxy class for {@link org.apache.hc.core5.http.HttpEntity} enclosed in a request message.
- *
- * @since 4.3
- */
-class RequestEntityProxy implements HttpEntity {
-
- static void enhance(final ClassicHttpRequest request) {
- final HttpEntity entity = request.getEntity();
- if (entity != null && !entity.isRepeatable() && !isEnhanced(entity)) {
- request.setEntity(new RequestEntityProxy(entity));
- }
- }
-
- static boolean isEnhanced(final HttpEntity entity) {
- return entity instanceof RequestEntityProxy;
- }
-
- private final HttpEntity original;
- private boolean consumed = false;
-
- RequestEntityProxy(final HttpEntity original) {
- super();
- this.original = original;
- }
-
- public HttpEntity getOriginal() {
- return original;
- }
-
- public boolean isConsumed() {
- return consumed;
- }
-
- @Override
- public boolean isRepeatable() {
- if (!consumed) {
- return true;
- } else {
- return original.isRepeatable();
- }
- }
-
- @Override
- public boolean isChunked() {
- return original.isChunked();
- }
-
- @Override
- public long getContentLength() {
- return original.getContentLength();
- }
-
- @Override
- public String getContentType() {
- return original.getContentType();
- }
-
- @Override
- public String getContentEncoding() {
- return original.getContentEncoding();
- }
-
- @Override
- public InputStream getContent() throws IOException, IllegalStateException {
- return original.getContent();
- }
-
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- consumed = true;
- original.writeTo(outstream);
- }
-
- @Override
- public boolean isStreaming() {
- return original.isStreaming();
- }
-
- @Override
- public Supplier<List<? extends Header>> getTrailers() {
- return original.getTrailers();
- }
-
- @Override
- public Set<String> getTrailerNames() {
- return original.getTrailerNames();
- }
-
- @Override
- public void close() throws IOException {
- original.close();
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("RequestEntityProxy{");
- sb.append(original);
- sb.append('}');
- return sb.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestFailedException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestFailedException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestFailedException.java
deleted file mode 100644
index cd084ab..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RequestFailedException.java
+++ /dev/null
@@ -1,52 +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.hc.client5.http.impl.sync;
-
-import java.io.InterruptedIOException;
-
-/**
- * Signals that the request has been aborted or failed due to an expected condition.
- *
- * @since 5.0
- */
-public class RequestFailedException extends InterruptedIOException {
-
- private static final long serialVersionUID = 4973849966012490112L;
-
- public RequestFailedException(final String message) {
- super(message);
- }
-
- public RequestFailedException(final String message, final Throwable cause) {
- super(message);
- if (cause != null) {
- initCause(cause);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ResponseEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ResponseEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ResponseEntityProxy.java
deleted file mode 100644
index 88a4c88..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ResponseEntityProxy.java
+++ /dev/null
@@ -1,158 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.SocketException;
-
-import org.apache.hc.client5.http.sync.ExecRuntime;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.io.EofSensorInputStream;
-import org.apache.hc.core5.http.io.EofSensorWatcher;
-import org.apache.hc.core5.http.io.entity.HttpEntityWrapper;
-
-/**
- * A wrapper class for {@link HttpEntity} enclosed in a response message.
- *
- * @since 4.3
- */
-class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher {
-
- private final ExecRuntime execRuntime;
-
- public static void enchance(final ClassicHttpResponse response, final ExecRuntime execRuntime) {
- final HttpEntity entity = response.getEntity();
- if (entity != null && entity.isStreaming() && execRuntime != null) {
- response.setEntity(new ResponseEntityProxy(entity, execRuntime));
- }
- }
-
- ResponseEntityProxy(final HttpEntity entity, final ExecRuntime execRuntime) {
- super(entity);
- this.execRuntime = execRuntime;
- }
-
- private void cleanup() throws IOException {
- if (this.execRuntime != null) {
- if (this.execRuntime.isConnected()) {
- this.execRuntime.disconnect();
- }
- this.execRuntime.discardConnection();
- }
- }
-
- private void discardConnection() {
- if (this.execRuntime != null) {
- this.execRuntime.discardConnection();
- }
- }
-
- public void releaseConnection() {
- if (this.execRuntime != null) {
- this.execRuntime.releaseConnection();
- }
- }
-
- @Override
- public boolean isRepeatable() {
- return false;
- }
-
- @Override
- public InputStream getContent() throws IOException {
- return new EofSensorInputStream(super.getContent(), this);
- }
-
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- try {
- if (outstream != null) {
- super.writeTo(outstream);
- }
- releaseConnection();
- } catch (IOException | RuntimeException ex) {
- discardConnection();
- throw ex;
- } finally {
- cleanup();
- }
- }
-
- @Override
- public boolean eofDetected(final InputStream wrapped) throws IOException {
- try {
- // there may be some cleanup required, such as
- // reading trailers after the response body:
- if (wrapped != null) {
- wrapped.close();
- }
- releaseConnection();
- } catch (IOException | RuntimeException ex) {
- discardConnection();
- throw ex;
- } finally {
- cleanup();
- }
- return false;
- }
-
- @Override
- public boolean streamClosed(final InputStream wrapped) throws IOException {
- try {
- final boolean open = execRuntime != null && execRuntime.isConnectionAcquired();
- // this assumes that closing the stream will
- // consume the remainder of the response body:
- try {
- if (wrapped != null) {
- wrapped.close();
- }
- releaseConnection();
- } catch (final SocketException ex) {
- if (open) {
- throw ex;
- }
- }
- } catch (IOException | RuntimeException ex) {
- discardConnection();
- throw ex;
- } finally {
- cleanup();
- }
- return false;
- }
-
- @Override
- public boolean streamAbort(final InputStream wrapped) throws IOException {
- cleanup();
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RetryExec.java
deleted file mode 100644
index 09d0d1a..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RetryExec.java
+++ /dev/null
@@ -1,127 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-
-import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.impl.ExecSupport;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.protocol.NonRepeatableRequestException;
-import org.apache.hc.client5.http.sync.ExecChain;
-import org.apache.hc.client5.http.sync.ExecChainHandler;
-import org.apache.hc.client5.http.sync.HttpRequestRetryHandler;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.NoHttpResponseException;
-import org.apache.hc.core5.util.Args;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * Request executor in the request execution chain that is responsible
- * for making a decision whether a request failed due to an I/O error
- * should be re-executed.
- * <p>
- * Further responsibilities such as communication with the opposite
- * endpoint is delegated to the next executor in the request execution
- * chain.
- * </p>
- *
- * @since 4.3
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-final class RetryExec implements ExecChainHandler {
-
- private final Logger log = LogManager.getLogger(getClass());
-
- private final HttpRequestRetryHandler retryHandler;
-
- public RetryExec(
- final HttpRequestRetryHandler retryHandler) {
- Args.notNull(retryHandler, "HTTP request retry handler");
- this.retryHandler = retryHandler;
- }
-
- @Override
- public ClassicHttpResponse execute(
- final ClassicHttpRequest request,
- final ExecChain.Scope scope,
- final ExecChain chain) throws IOException, HttpException {
- Args.notNull(request, "HTTP request");
- Args.notNull(scope, "Scope");
- final HttpRoute route = scope.route;
- final HttpClientContext context = scope.clientContext;
- ClassicHttpRequest currentRequest = request;
- for (int execCount = 1;; execCount++) {
- try {
- return chain.proceed(currentRequest, scope);
- } catch (final IOException ex) {
- if (scope.execRuntime.isExecutionAborted()) {
- throw new RequestFailedException("Request aborted");
- }
- if (retryHandler.retryRequest(request, ex, execCount, context)) {
- if (this.log.isInfoEnabled()) {
- this.log.info("I/O exception ("+ ex.getClass().getName() +
- ") caught when processing request to "
- + route +
- ": "
- + ex.getMessage());
- }
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage(), ex);
- }
- final HttpEntity entity = request.getEntity();
- if (entity != null && !entity.isRepeatable()) {
- this.log.debug("Cannot retry non-repeatable request");
- throw new NonRepeatableRequestException("Cannot retry request " +
- "with a non-repeatable request entity", ex);
- }
- currentRequest = ExecSupport.copy(scope.originalRequest);
- if (this.log.isInfoEnabled()) {
- this.log.info("Retrying request to " + route);
- }
- } else {
- if (ex instanceof NoHttpResponseException) {
- final NoHttpResponseException updatedex = new NoHttpResponseException(
- route.getTargetHost().toHostString() + " failed to respond");
- updatedex.setStackTrace(ex.getStackTrace());
- throw updatedex;
- } else {
- throw ex;
- }
- }
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ServiceUnavailableRetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ServiceUnavailableRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ServiceUnavailableRetryExec.java
deleted file mode 100644
index 721f98d..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ServiceUnavailableRetryExec.java
+++ /dev/null
@@ -1,115 +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.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-
-import org.apache.hc.client5.http.impl.ExecSupport;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.sync.ExecChain;
-import org.apache.hc.client5.http.sync.ExecChainHandler;
-import org.apache.hc.client5.http.sync.ServiceUnavailableRetryStrategy;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.util.Args;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * Request executor in the request execution chain that is responsible
- * for making a decision whether a request that received a non-2xx response
- * from the target server should be re-executed.
- * <p>
- * Further responsibilities such as communication with the opposite
- * endpoint is delegated to the next executor in the request execution
- * chain.
- * </p>
- *
- * @since 4.3
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-final class ServiceUnavailableRetryExec implements ExecChainHandler {
-
- private final Logger log = LogManager.getLogger(getClass());
-
- private final ServiceUnavailableRetryStrategy retryStrategy;
-
- public ServiceUnavailableRetryExec(
- final ServiceUnavailableRetryStrategy retryStrategy) {
- super();
- Args.notNull(retryStrategy, "Retry strategy");
- this.retryStrategy = retryStrategy;
- }
-
- @Override
- public ClassicHttpResponse execute(
- final ClassicHttpRequest request,
- final ExecChain.Scope scope,
- final ExecChain chain) throws IOException, HttpException {
- Args.notNull(request, "HTTP request");
- Args.notNull(scope, "Scope");
- final HttpClientContext context = scope.clientContext;
- ClassicHttpRequest currentRequest = request;
- for (int c = 1;; c++) {
- final ClassicHttpResponse response = chain.proceed(currentRequest, scope);
- try {
- final HttpEntity entity = request.getEntity();
- if (entity != null && !entity.isRepeatable()) {
- return response;
- }
- if (this.retryStrategy.retryRequest(response, c, context)) {
- response.close();
- final long nextInterval = this.retryStrategy.getRetryInterval(response, context);
- if (nextInterval > 0) {
- try {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Wait for " + ((double) nextInterval / 1000) + " seconds" );
- }
- Thread.sleep(nextInterval);
- } catch (final InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new InterruptedIOException();
- }
- }
- currentRequest = ExecSupport.copy(scope.originalRequest);
- } else {
- return response;
- }
- } catch (final RuntimeException ex) {
- response.close();
- throw ex;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/SystemClock.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/SystemClock.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/SystemClock.java
deleted file mode 100644
index 7c5d210..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/SystemClock.java
+++ /dev/null
@@ -1,41 +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.hc.client5.http.impl.sync;
-
-/**
- * The actual system clock.
- *
- * @since 4.2
- */
-class SystemClock implements Clock {
-
- @Override
- public long getCurrentTime() {
- return System.currentTimeMillis();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/TunnelRefusedException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/TunnelRefusedException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/TunnelRefusedException.java
deleted file mode 100644
index fe78cd7..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/TunnelRefusedException.java
+++ /dev/null
@@ -1,52 +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.hc.client5.http.impl.sync;
-
-import org.apache.hc.core5.http.HttpException;
-
-/**
- * Signals that the tunnel request was rejected by the proxy host.
- *
- * @since 4.0
- */
-public class TunnelRefusedException extends HttpException {
-
- private static final long serialVersionUID = -8646722842745617323L;
-
- private final String responseMesage;
-
- public TunnelRefusedException(final String message, final String responseMesage) {
- super(message);
- this.responseMesage = responseMesage;
- }
-
- public String getResponseMessage() {
- return this.responseMesage;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/package-info.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/package-info.java
deleted file mode 100644
index 92326c3..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/package-info.java
+++ /dev/null
@@ -1,52 +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/>.
- *
- */
-
-/**
- * Default HTTP client implementation.
- * <p>
- * The usual execution flow can be demonstrated by the code snippet below:
- * </p>
- * <pre>
- * CloseableHttpClient httpclient = HttpClients.createDefault();
- * try {
- * HttpGet httpGet = new HttpGet("http://targethost/homepage");
- * CloseableHttpResponse response = httpclient.execute(httpGet);
- * try {
- * System.out.println(response.getStatusLine());
- * HttpEntity entity = response.getEntity();
- * // do something useful with the response body
- * // and ensure it is fully consumed
- * EntityUtils.consume(entity);
- * } finally {
- * response.close();
- * }
- * } finally {
- * httpclient.close();
- * }
- * </pre>
- */
-package org.apache.hc.client5.http.impl.sync;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/AuthenticationStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/AuthenticationStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/AuthenticationStrategy.java
deleted file mode 100644
index 7432a43..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/AuthenticationStrategy.java
+++ /dev/null
@@ -1,65 +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.hc.client5.http.protocol;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hc.client5.http.auth.AuthChallenge;
-import org.apache.hc.client5.http.auth.AuthScheme;
-import org.apache.hc.client5.http.auth.ChallengeType;
-import org.apache.hc.core5.http.protocol.HttpContext;
-
-/**
- * Strategy to select auth schemes in order of preference based on auth challenges
- * presented by the opposite endpoint (target server or a proxy).
- * <p>
- * Implementations of this interface must be thread-safe. Access to shared data must be
- * synchronized as methods of this interface may be executed from multiple threads.
- *
- * @since 4.2
- */
-public interface AuthenticationStrategy {
-
- /**
- * Returns an list of {@link AuthScheme}s to handle the given {@link AuthChallenge}s
- * in their order of preference.
- *
- * @param challengeType challenge type.
- * @param challenges collection of challenges.
- * @param context HTTP context.
- * @return authentication auth schemes that can be used for authentication. Can be empty.
- *
- * @since 5.0
- */
- List<AuthScheme> select(
- ChallengeType challengeType,
- Map<String, AuthChallenge> challenges,
- HttpContext context);
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/CircularRedirectException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/CircularRedirectException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/CircularRedirectException.java
deleted file mode 100644
index e864a81..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/CircularRedirectException.java
+++ /dev/null
@@ -1,65 +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.hc.client5.http.protocol;
-
-/**
- * Signals a circular redirect
- *
- *
- * @since 4.0
- */
-public class CircularRedirectException extends RedirectException {
-
- private static final long serialVersionUID = 6830063487001091803L;
-
- /**
- * Creates a new CircularRedirectException with a {@code null} detail message.
- */
- public CircularRedirectException() {
- super();
- }
-
- /**
- * Creates a new CircularRedirectException with the specified detail message.
- *
- * @param message The exception detail message
- */
- public CircularRedirectException(final String message) {
- super(message);
- }
-
- /**
- * Creates a new CircularRedirectException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the {@code Throwable} that caused this exception, or {@code null}
- * if the cause is unavailable, unknown, or not a {@code Throwable}
- */
- public CircularRedirectException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/ClientProtocolException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/ClientProtocolException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/ClientProtocolException.java
deleted file mode 100644
index 860c3df..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/ClientProtocolException.java
+++ /dev/null
@@ -1,58 +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.hc.client5.http.protocol;
-
-import java.io.IOException;
-
-/**
- * Signals an error in the HTTP protocol.
- *
- * @since 4.0
- */
-public class ClientProtocolException extends IOException {
-
- private static final long serialVersionUID = -5596590843227115865L;
-
- public ClientProtocolException() {
- super();
- }
-
- public ClientProtocolException(final String s) {
- super(s);
- }
-
- public ClientProtocolException(final Throwable cause) {
- initCause(cause);
- }
-
- public ClientProtocolException(final String message, final Throwable cause) {
- super(message);
- initCause(cause);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpResponseException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpResponseException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpResponseException.java
deleted file mode 100644
index 831fb29..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpResponseException.java
+++ /dev/null
@@ -1,49 +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.hc.client5.http.protocol;
-
-/**
- * Signals a non 2xx HTTP response.
- *
- * @since 4.0
- */
-public class HttpResponseException extends ClientProtocolException {
-
- private static final long serialVersionUID = -7186627969477257933L;
-
- private final int statusCode;
-
- public HttpResponseException(final int statusCode, final String s) {
- super(s);
- this.statusCode = statusCode;
- }
-
- public int getStatusCode() {
- return this.statusCode;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/NonRepeatableRequestException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/NonRepeatableRequestException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/NonRepeatableRequestException.java
deleted file mode 100644
index 7f8fc07..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/NonRepeatableRequestException.java
+++ /dev/null
@@ -1,70 +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.hc.client5.http.protocol;
-
-import org.apache.hc.core5.http.ProtocolException;
-
-/**
- * Signals failure to retry the request due to non-repeatable request
- * entity.
- *
- *
- * @since 4.0
- */
-public class NonRepeatableRequestException extends ProtocolException {
-
- private static final long serialVersionUID = 82685265288806048L;
-
- /**
- * Creates a new NonRepeatableEntityException with a {@code null} detail message.
- */
- public NonRepeatableRequestException() {
- super();
- }
-
- /**
- * Creates a new NonRepeatableEntityException with the specified detail message.
- *
- * @param message The exception detail message
- */
- public NonRepeatableRequestException(final String message) {
- super(message);
- }
-
- /**
- * Creates a new NonRepeatableEntityException with the specified detail message.
- *
- * @param message The exception detail message
- * @param cause the cause
- */
- public NonRepeatableRequestException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RedirectException.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RedirectException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RedirectException.java
deleted file mode 100644
index 8151b94..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RedirectException.java
+++ /dev/null
@@ -1,67 +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.hc.client5.http.protocol;
-
-import org.apache.hc.core5.http.ProtocolException;
-
-/**
- * Signals violation of HTTP specification caused by an invalid redirect
- *
- *
- * @since 4.0
- */
-public class RedirectException extends ProtocolException {
-
- private static final long serialVersionUID = 4418824536372559326L;
-
- /**
- * Creates a new RedirectException with a {@code null} detail message.
- */
- public RedirectException() {
- super();
- }
-
- /**
- * Creates a new RedirectException with the specified detail message.
- *
- * @param message The exception detail message
- */
- public RedirectException(final String message) {
- super(message);
- }
-
- /**
- * Creates a new RedirectException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the {@code Throwable} that caused this exception, or {@code null}
- * if the cause is unavailable, unknown, or not a {@code Throwable}
- */
- public RedirectException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/UserTokenHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/UserTokenHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/UserTokenHandler.java
deleted file mode 100644
index 497763d..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/UserTokenHandler.java
+++ /dev/null
@@ -1,61 +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.hc.client5.http.protocol;
-
-import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.core5.http.protocol.HttpContext;
-
-/**
- * A handler for determining if the given execution context is user specific
- * or not. The token object returned by this handler is expected to uniquely
- * identify the current user if the context is user specific or to be
- * {@code null} if the context does not contain any resources or details
- * specific to the current user.
- * <p>
- * The user token will be used to ensure that user specific resources will not
- * be shared with or reused by other users.
- * </p>
- *
- * @since 4.0
- */
-public interface UserTokenHandler {
-
- /**
- * The token object returned by this method is expected to uniquely
- * identify the current user if the context is user specific or to be
- * {@code null} if it is not.
- *
- * @param route HTTP route
- * @param context the execution context
- *
- * @return user token that uniquely identifies the user or
- * {@code null} if the context is not user specific.
- */
- Object getUserToken(HttpRoute route, HttpContext context);
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/6d17126c/httpclient5/src/main/java/org/apache/hc/client5/http/sync/BackoffManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/sync/BackoffManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/sync/BackoffManager.java
deleted file mode 100644
index 93acc3a..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/sync/BackoffManager.java
+++ /dev/null
@@ -1,54 +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.hc.client5.http.sync;
-
-import org.apache.hc.client5.http.HttpRoute;
-
-/**
- * Represents a controller that dynamically adjusts the size
- * of an available connection pool based on feedback from
- * using the connections.
- *
- * @since 4.2
- *
- */
-public interface BackoffManager {
-
- /**
- * Called when we have decided that the result of
- * using a connection should be interpreted as a
- * backoff signal.
- */
- void backOff(HttpRoute route);
-
- /**
- * Called when we have determined that the result of
- * using a connection has succeeded and that we may
- * probe for more connections.
- */
- void probe(HttpRoute route);
-}