{
// key should have destination at this point (will be replaced by endpoint after this call)
HttpDestination dest=(HttpDestination)key.attachment();
SelectChannelEndPoint ep=null;
if (dest.isSecure())
{
if (dest.isProxied())
{
String connect = HttpMethods.CONNECT+" "+dest.getAddress()+HttpVersions.HTTP_1_0+"\r\n\r\n";
// TODO need to send this over channel unencrypted and setup endpoint to ignore the 200 OK response.
throw new IllegalStateException("Not Implemented");
}
SSLEngine engine=newSslEngine();
ep = new SslHttpChannelEndPoint(_sslBuffers,channel,selectSet,key,engine);
}
else
{
ep=new SelectChannelEndPoint(channel,selectSet,key);
}
HttpConnection connection=(HttpConnection)ep.getConnection();
connection.setDestination(dest);
dest.onNewConnection(connection);
return ep;
}