Classic exec runtime to establish connection automatically if the connection endpoint is disconnected
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1794169 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
196ee3363e
commit
ecf4e93842
|
@ -202,10 +202,6 @@ public final class ConnectExec implements ExecChainHandler {
|
|||
this.proxyHttpProcessor.process(connect, null, context);
|
||||
|
||||
while (response == null) {
|
||||
if (!execRuntime.isConnected()) {
|
||||
execRuntime.connect(context);
|
||||
}
|
||||
|
||||
connect.removeHeaders(HttpHeaders.PROXY_AUTHORIZATION);
|
||||
this.authenticator.addAuthResponse(proxy, ChallengeType.PROXY, connect, proxyAuthExchange, context);
|
||||
|
||||
|
|
|
@ -141,22 +141,26 @@ class ExecRuntimeImpl implements ExecRuntime, Cancellable {
|
|||
return endpoint != null && endpoint.isConnected();
|
||||
}
|
||||
|
||||
private void connectEndpoint(final ConnectionEndpoint endpoint, final HttpClientContext context) throws IOException {
|
||||
if (cancellableAware != null) {
|
||||
if (cancellableAware.isCancelled()) {
|
||||
throw new RequestFailedException("Request aborted");
|
||||
}
|
||||
}
|
||||
final RequestConfig requestConfig = context.getRequestConfig();
|
||||
final TimeValue connectTimeout = requestConfig.getConnectTimeout();
|
||||
manager.connect(endpoint, connectTimeout, context);
|
||||
final TimeValue socketTimeout = requestConfig.getSocketTimeout();
|
||||
if (socketTimeout.getDuration() >= 0) {
|
||||
endpoint.setSocketTimeout(socketTimeout.toMillisIntBound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(final HttpClientContext context) throws IOException {
|
||||
final ConnectionEndpoint endpoint = ensureValid();
|
||||
if (!endpoint.isConnected()) {
|
||||
if (cancellableAware != null) {
|
||||
if (cancellableAware.isCancelled()) {
|
||||
throw new RequestFailedException("Request aborted");
|
||||
}
|
||||
}
|
||||
final RequestConfig requestConfig = context.getRequestConfig();
|
||||
final TimeValue connectTimeout = requestConfig.getConnectTimeout();
|
||||
manager.connect(endpoint, connectTimeout, context);
|
||||
final TimeValue socketTimeout = requestConfig.getSocketTimeout();
|
||||
if (socketTimeout.getDuration() >= 0) {
|
||||
endpoint.setSocketTimeout(socketTimeout.toMillisIntBound());
|
||||
}
|
||||
connectEndpoint(endpoint, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +182,9 @@ class ExecRuntimeImpl implements ExecRuntime, Cancellable {
|
|||
@Override
|
||||
public ClassicHttpResponse execute(final ClassicHttpRequest request, final HttpClientContext context) throws IOException, HttpException {
|
||||
final ConnectionEndpoint endpoint = ensureValid();
|
||||
if (!endpoint.isConnected()) {
|
||||
connectEndpoint(endpoint, context);
|
||||
}
|
||||
return endpoint.execute(request, requestExecutor, context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue