if (tracker.isLayered()) {
throw new IllegalStateException("Multiple protocol layering not supported");
}
final HttpHost target = tracker.getTargetHost();
final AsyncScheme scheme = getSchemeRegistry(context).getScheme(target);
final LayeringStrategy layeringStrategy = scheme.getLayeringStrategy();
if (layeringStrategy == null) {
throw new IllegalStateException(scheme.getName() +
" scheme does not provider support for protocol layering");
}
final IOSession iosession = entry.getConnection();
final ClientAsyncConnection conn = (ClientAsyncConnection) iosession.getAttribute(
IOEventDispatch.CONNECTION_KEY);
conn.upgrade((SSLIOSession) layeringStrategy.layer(iosession));
tracker.layerProtocol(layeringStrategy.isSecure());
}