Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-10-05 09:52:58 +0000
committerSimone Bordet2015-10-05 09:52:58 +0000
commit399755b352b37e02f5baf211870de14072d8a0df (patch)
tree7706f6cfee9474835a59a062090abdb1a98a74e4 /jetty-client
parent6aae1265bd71c87c671061d9c70a25fd5056d18d (diff)
downloadorg.eclipse.jetty.project-399755b352b37e02f5baf211870de14072d8a0df.tar.gz
org.eclipse.jetty.project-399755b352b37e02f5baf211870de14072d8a0df.tar.xz
org.eclipse.jetty.project-399755b352b37e02f5baf211870de14072d8a0df.zip
479026 - Wrong CONNECT request idle timeout.
Explicitly set the CONNECT request idle timeout instead of inheriting HttpClient's.
Diffstat (limited to 'jetty-client')
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java35
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java9
2 files changed, 21 insertions, 23 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
index c46bc6cd35..c8b5556af4 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.http.HttpConnectionOverHTTP;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
@@ -119,7 +118,7 @@ public class HttpProxy extends ProxyConfiguration.Proxy
{
String message = String.format("Cannot perform requests over SSL, no %s in %s",
SslContextFactory.class.getSimpleName(), HttpClient.class.getSimpleName());
- promise.failed(new IllegalStateException(message));
+ tunnelFailed(new IllegalStateException(message));
}
}
else
@@ -131,7 +130,7 @@ public class HttpProxy extends ProxyConfiguration.Proxy
@Override
public void failed(Throwable x)
{
- promise.failed(x);
+ tunnelFailed(x);
}
private void tunnel(HttpDestination destination, final Connection connection)
@@ -139,33 +138,31 @@ public class HttpProxy extends ProxyConfiguration.Proxy
String target = destination.getOrigin().getAddress().asString();
Origin.Address proxyAddress = destination.getConnectAddress();
HttpClient httpClient = destination.getHttpClient();
+ long connectTimeout = httpClient.getConnectTimeout();
Request connect = httpClient.newRequest(proxyAddress.getHost(), proxyAddress.getPort())
.scheme(HttpScheme.HTTP.asString())
.method(HttpMethod.CONNECT)
.path(target)
.header(HttpHeader.HOST, target)
- .timeout(httpClient.getConnectTimeout(), TimeUnit.MILLISECONDS);
+ .idleTimeout(2 * connectTimeout, TimeUnit.MILLISECONDS)
+ .timeout(connectTimeout, TimeUnit.MILLISECONDS);
- connection.send(connect, new Response.CompleteListener()
+ connection.send(connect, result ->
{
- @Override
- public void onComplete(Result result)
+ if (result.isFailed())
{
- if (result.isFailed())
+ tunnelFailed(result.getFailure());
+ }
+ else
+ {
+ Response response = result.getResponse();
+ if (response.getStatus() == 200)
{
- tunnelFailed(result.getFailure());
+ tunnelSucceeded();
}
else
{
- Response response = result.getResponse();
- if (response.getStatus() == 200)
- {
- tunnelSucceeded();
- }
- else
- {
- tunnelFailed(new HttpResponseException("Received " + response + " for " + result.getRequest(), response));
- }
+ tunnelFailed(new HttpResponseException("Received " + response + " for " + result.getRequest(), response));
}
}
});
@@ -198,7 +195,7 @@ public class HttpProxy extends ProxyConfiguration.Proxy
private void tunnelFailed(Throwable failure)
{
endPoint.close();
- failed(failure);
+ promise.failed(failure);
}
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
index 3030a97658..9f0aff8703 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
@@ -168,11 +168,11 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
}
@Override
- public void close(Connection oldConnection)
+ public void close(Connection connection)
{
- super.close(oldConnection);
+ super.close(connection);
- connectionPool.remove(oldConnection);
+ boolean removed = connectionPool.remove(connection);
if (getHttpExchanges().isEmpty())
{
@@ -192,7 +192,8 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
// We need to execute queued requests even if this connection failed.
// We may create a connection that is not needed, but it will eventually
// idle timeout, so no worries.
- process();
+ if (removed)
+ process();
}
}

Back to the top