rh = new BufferingHttpRequestHandler(rh, bmi, 10240);
HttpProxyConnectionHandler hpch = new HttpProxyConnectionHandler(rh);
SSLContextSelector cp = getSSLContextSelector();
TargetedConnectionHandler tch = new SSLConnectionHandler(cp, true, hpch);
tch = new LoopAvoidingTargetedConnectionHandler(sg, tch);
hpch.setConnectHandler(tch);
TargetedConnectionHandler socks = new SocksConnectionHandler(tch, true);
mainProxy = new Proxy(mainListener, socks, null);
mainProxy.setSocketTimeout(90000);
mainProxy.start();