413531 - Introduce pluggable transports for HttpClient.

Merge of the branch 'http_client_transport' is now complete,
and the implementation is sound for the HTTP transport.
A basic implementation for the SPDY transport exists, but needs
improvements.
This commit is contained in:
Simone Bordet 2013-07-23 15:19:36 +02:00
parent 86d51f057d
commit d0f0dedf20
5 changed files with 22 additions and 17 deletions

View File

@ -914,22 +914,6 @@ public class HttpClient extends ContainerLifeCycle
dump(out, indent, getBeans(), destinations.values());
}
protected Connection tunnel(Connection connection)
{
// TODO
/*
HttpConnection httpConnection = (HttpConnection)connection;
HttpDestination destination = httpConnection.getHttpDestination();
SslConnection sslConnection = createSslConnection(destination, httpConnection.getEndPoint());
Connection result = (Connection)sslConnection.getDecryptedEndPoint().getConnection();
selectorManager.connectionClosed(httpConnection);
selectorManager.connectionOpened(sslConnection);
LOG.debug("Tunnelled {} over {}", connection, result);
return result;
*/
return connection;
}
private class ContentDecoderFactorySet implements Set<ContentDecoder.Factory>
{
private final Set<ContentDecoder.Factory> set = new HashSet<>();

View File

@ -30,4 +30,6 @@ public interface HttpClientTransport
HttpDestination newHttpDestination(HttpClient httpClient, String scheme, String host, int port);
void connect(HttpDestination destination, SocketAddress address, Promise<Connection> promise);
Connection tunnel(Connection connection);
}

View File

@ -330,7 +330,7 @@ public abstract class HttpDestination implements Destination, Closeable, Dumpabl
if (response.getStatus() == 200)
{
// Wrap the connection with TLS
Connection tunnel = client.tunnel(connection);
Connection tunnel = client.getTransport().tunnel(connection);
delegate.succeeded(tunnel);
}
else

View File

@ -107,6 +107,19 @@ public class HttpClientTransportOverHTTP extends ContainerLifeCycle implements H
}
}
@Override
public org.eclipse.jetty.client.api.Connection tunnel(org.eclipse.jetty.client.api.Connection connection)
{
HttpConnectionOverHTTP httpConnection = (HttpConnectionOverHTTP)connection;
HttpDestination destination = httpConnection.getHttpDestination();
SslConnection sslConnection = createSslConnection(destination, httpConnection.getEndPoint());
HttpConnectionOverHTTP result = (HttpConnectionOverHTTP)sslConnection.getDecryptedEndPoint().getConnection();
selectorManager.connectionClosed(httpConnection);
selectorManager.connectionOpened(sslConnection);
LOG.debug("Tunnelled {} over {}", connection, result);
return result;
}
protected void configure(HttpClient client, SocketChannel channel) throws SocketException
{
channel.socket().setTcpNoDelay(client.isTCPNoDelay());

View File

@ -87,4 +87,10 @@ public class HttpClientTransportOverSPDY implements HttpClientTransport
}
);
}
@Override
public Connection tunnel(Connection connection)
{
throw new UnsupportedOperationException();
}
}