|
30 | 30 | import static com.ning.http.util.AsyncHttpProviderUtils.DEFAULT_CHARSET;
|
31 | 31 | import static com.ning.http.util.MiscUtil.isNonEmpty;
|
32 | 32 | import static org.jboss.netty.channel.Channels.pipeline;
|
| 33 | +import static org.jboss.netty.handler.ssl.SslHandler.getDefaultBufferPool; |
33 | 34 |
|
34 | 35 | import java.io.File;
|
35 | 36 | import java.io.FileInputStream;
|
|
97 | 98 | import org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder;
|
98 | 99 | import org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameEncoder;
|
99 | 100 | import org.jboss.netty.handler.codec.http.websocketx.WebSocketFrame;
|
| 101 | +import org.jboss.netty.handler.ssl.ImmediateExecutor; |
100 | 102 | import org.jboss.netty.handler.ssl.SslHandler;
|
101 | 103 | import org.jboss.netty.handler.stream.ChunkedFile;
|
102 | 104 | import org.jboss.netty.handler.stream.ChunkedWriteHandler;
|
|
129 | 131 | import com.ning.http.client.Request;
|
130 | 132 | import com.ning.http.client.RequestBuilder;
|
131 | 133 | import com.ning.http.client.Response;
|
132 |
| -import com.ning.http.client.cookie.Cookie; |
133 | 134 | import com.ning.http.client.cookie.CookieDecoder;
|
134 | 135 | import com.ning.http.client.cookie.CookieEncoder;
|
135 | 136 | import com.ning.http.client.filter.FilterContext;
|
@@ -215,6 +216,7 @@ public boolean remove(Object o) {
|
215 | 216 | private final Protocol webSocketProtocol = new WebSocketProtocol();
|
216 | 217 | private final boolean allowStopHashedWheelTimer;
|
217 | 218 | private final HashedWheelTimer hashedWheelTimer;
|
| 219 | + private final long handshakeTimeoutInMillis; |
218 | 220 |
|
219 | 221 | private static boolean isNTLM(List<String> auth) {
|
220 | 222 | return isNonEmpty(auth) && auth.get(0).startsWith("NTLM");
|
@@ -262,6 +264,8 @@ public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
|
262 | 264 | hashedWheelTimer = allowStopHashedWheelTimer ? new HashedWheelTimer() : providerConfig.getHashedWheelTimer();
|
263 | 265 | hashedWheelTimer.start();
|
264 | 266 |
|
| 267 | + handshakeTimeoutInMillis = providerConfig.getHandshakeTimeoutInMillis(); |
| 268 | + |
265 | 269 | plainBootstrap = new ClientBootstrap(socketChannelFactory);
|
266 | 270 | secureBootstrap = new ClientBootstrap(socketChannelFactory);
|
267 | 271 | webSocketBootstrap = new ClientBootstrap(socketChannelFactory);
|
@@ -367,7 +371,10 @@ public ChannelPipeline getPipeline() throws Exception {
|
367 | 371 | ChannelPipeline pipeline = pipeline();
|
368 | 372 |
|
369 | 373 | try {
|
370 |
| - pipeline.addLast(SSL_HANDLER, new SslHandler(createSSLEngine())); |
| 374 | + SSLEngine sslEngine = createSSLEngine(); |
| 375 | + SslHandler sslHandler = handshakeTimeoutInMillis > 0 ? new SslHandler(sslEngine, getDefaultBufferPool(), false, ImmediateExecutor.INSTANCE, hashedWheelTimer, |
| 376 | + handshakeTimeoutInMillis) : new SslHandler(sslEngine); |
| 377 | + pipeline.addLast(SSL_HANDLER, sslHandler); |
371 | 378 | } catch (Throwable ex) {
|
372 | 379 | abort(cl.future(), ex);
|
373 | 380 | }
|
@@ -1060,8 +1067,8 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
|
1060 | 1067 | }
|
1061 | 1068 |
|
1062 | 1069 | ChannelFuture channelFuture;
|
1063 |
| - ClientBootstrap bootstrap = (request.getUrl().startsWith(WEBSOCKET) && !useProxy) ? |
1064 |
| - (useSSl ? secureWebSocketBootstrap : webSocketBootstrap) : (useSSl ? secureBootstrap : plainBootstrap); |
| 1070 | + ClientBootstrap bootstrap = (request.getUrl().startsWith(WEBSOCKET) && !useProxy) ? (useSSl ? secureWebSocketBootstrap : webSocketBootstrap) : (useSSl ? secureBootstrap |
| 1071 | + : plainBootstrap); |
1065 | 1072 | bootstrap.setOption("connectTimeoutMillis", config.getConnectionTimeoutInMs());
|
1066 | 1073 |
|
1067 | 1074 | // Do no enable this with win.
|
|
0 commit comments