public void upgradeProtocol(ChannelPipeline pipeline, String scheme, String host, int port) throws IOException,
GeneralSecurityException {
if (pipeline.get(HTTP_HANDLER) != null)
pipeline.remove(HTTP_HANDLER);
if (isSecure(scheme))
if (isSslHandlerConfigured(pipeline)) {
pipeline.addAfter(SSL_HANDLER, HTTP_HANDLER, newHttpClientCodec());
} else {
pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec());
pipeline.addFirst(SSL_HANDLER, createSslHandler(host, port));
}
else
pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec());
if (isWebSocket(scheme)) {
pipeline.addAfter(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor);
pipeline.remove(HTTP_PROCESSOR);
}
}