Skip to content

Commit 898c4a4

Browse files
author
Stephane Landelle
committed
Handshake is done automatically
1 parent 8c2caa2 commit 898c4a4

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/NettyConnectListener.java

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,26 @@
1616
*/
1717
package org.asynchttpclient.providers.netty4;
1818

19+
import io.netty.channel.Channel;
20+
import io.netty.channel.ChannelFuture;
21+
import io.netty.channel.ChannelFutureListener;
22+
import io.netty.handler.codec.http.HttpRequest;
23+
import io.netty.handler.ssl.SslHandler;
24+
1925
import java.io.IOException;
2026
import java.net.ConnectException;
2127
import java.net.URI;
2228
import java.nio.channels.ClosedChannelException;
23-
import java.util.concurrent.atomic.AtomicBoolean;
2429

2530
import javax.net.ssl.HostnameVerifier;
2631

27-
import io.netty.channel.Channel;
28-
import io.netty.channel.ChannelFuture;
29-
import io.netty.channel.ChannelFutureListener;
30-
import io.netty.handler.codec.http.HttpRequest;
31-
import io.netty.handler.ssl.SslHandler;
32-
import io.netty.util.concurrent.Future;
33-
import io.netty.util.concurrent.GenericFutureListener;
34-
35-
import org.slf4j.Logger;
36-
import org.slf4j.LoggerFactory;
3732
import org.asynchttpclient.AsyncHandler;
3833
import org.asynchttpclient.AsyncHttpClientConfig;
3934
import org.asynchttpclient.ProxyServer;
4035
import org.asynchttpclient.Request;
4136
import org.asynchttpclient.util.ProxyUtils;
37+
import org.slf4j.Logger;
38+
import org.slf4j.LoggerFactory;
4239

4340
/**
4441
* Non Blocking connect.
@@ -50,7 +47,6 @@ final class NettyConnectListener<T> implements ChannelFutureListener {
5047
private final AsyncHttpClientConfig config;
5148
private final NettyRequestSender requestSender;
5249
private final NettyResponseFuture<T> future;
53-
private final AtomicBoolean handshakeDone = new AtomicBoolean(false);
5450

5551
private NettyConnectListener(AsyncHttpClientConfig config, NettyRequestSender requestSender, NettyResponseFuture<T> future) {
5652
this.requestSender = requestSender;
@@ -67,19 +63,7 @@ private void onFutureSuccess(final Channel channel) throws Exception {
6763
SslHandler sslHandler = Channels.getSslHandler(channel);
6864

6965
if (sslHandler != null) {
70-
if (!handshakeDone.getAndSet(true)) {
71-
sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<Channel>>() {
72-
public void operationComplete(Future<Channel> f) throws Exception {
73-
if (f.isSuccess()) {
74-
onFutureSuccess(channel);
75-
} else {
76-
onFutureFailure(channel, f.cause());
77-
}
78-
}
79-
});
80-
return;
81-
}
82-
66+
// FIXME done on connect or on every request?
8367
HostnameVerifier v = config.getHostnameVerifier();
8468
if (!v.verify(future.getURI().getHost(), sslHandler.engine().getSession())) {
8569
ConnectException exception = new ConnectException("HostnameVerifier exception.");

0 commit comments

Comments
 (0)