16
16
*/
17
17
package org .asynchttpclient .providers .netty4 ;
18
18
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
+
19
25
import java .io .IOException ;
20
26
import java .net .ConnectException ;
21
27
import java .net .URI ;
22
28
import java .nio .channels .ClosedChannelException ;
23
- import java .util .concurrent .atomic .AtomicBoolean ;
24
29
25
30
import javax .net .ssl .HostnameVerifier ;
26
31
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 ;
37
32
import org .asynchttpclient .AsyncHandler ;
38
33
import org .asynchttpclient .AsyncHttpClientConfig ;
39
34
import org .asynchttpclient .ProxyServer ;
40
35
import org .asynchttpclient .Request ;
41
36
import org .asynchttpclient .util .ProxyUtils ;
37
+ import org .slf4j .Logger ;
38
+ import org .slf4j .LoggerFactory ;
42
39
43
40
/**
44
41
* Non Blocking connect.
@@ -50,7 +47,6 @@ final class NettyConnectListener<T> implements ChannelFutureListener {
50
47
private final AsyncHttpClientConfig config ;
51
48
private final NettyRequestSender requestSender ;
52
49
private final NettyResponseFuture <T > future ;
53
- private final AtomicBoolean handshakeDone = new AtomicBoolean (false );
54
50
55
51
private NettyConnectListener (AsyncHttpClientConfig config , NettyRequestSender requestSender , NettyResponseFuture <T > future ) {
56
52
this .requestSender = requestSender ;
@@ -67,19 +63,7 @@ private void onFutureSuccess(final Channel channel) throws Exception {
67
63
SslHandler sslHandler = Channels .getSslHandler (channel );
68
64
69
65
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?
83
67
HostnameVerifier v = config .getHostnameVerifier ();
84
68
if (!v .verify (future .getURI ().getHost (), sslHandler .engine ().getSession ())) {
85
69
ConnectException exception = new ConnectException ("HostnameVerifier exception." );
0 commit comments