32
32
import java .util .List ;
33
33
34
34
import org .apache .hc .client5 .http .impl .DefaultClientConnectionReuseStrategy ;
35
+ import org .apache .hc .core5 .function .Callback ;
35
36
import org .apache .hc .core5 .http .ConnectionReuseStrategy ;
36
37
import org .apache .hc .core5 .http .Header ;
37
38
import org .apache .hc .core5 .http .HttpConnection ;
@@ -85,14 +86,16 @@ class HttpAsyncClientProtocolNegotiationStarter implements IOEventHandlerFactory
85
86
private final ConnectionReuseStrategy http1ConnectionReuseStrategy ;
86
87
private final NHttpMessageParserFactory <HttpResponse > http1ResponseParserFactory ;
87
88
private final NHttpMessageWriterFactory <HttpRequest > http1RequestWriterFactory ;
89
+ private final Callback <Exception > exceptionCallback ;
88
90
89
91
HttpAsyncClientProtocolNegotiationStarter (
90
92
final HttpProcessor httpProcessor ,
91
93
final HandlerFactory <AsyncPushConsumer > exchangeHandlerFactory ,
92
94
final H2Config h2Config ,
93
95
final Http1Config h1Config ,
94
96
final CharCodingConfig charCodingConfig ,
95
- final ConnectionReuseStrategy connectionReuseStrategy ) {
97
+ final ConnectionReuseStrategy connectionReuseStrategy ,
98
+ final Callback <Exception > exceptionCallback ) {
96
99
this .httpProcessor = Args .notNull (httpProcessor , "HTTP processor" );
97
100
this .exchangeHandlerFactory = exchangeHandlerFactory ;
98
101
this .h2Config = h2Config != null ? h2Config : H2Config .DEFAULT ;
@@ -101,6 +104,7 @@ class HttpAsyncClientProtocolNegotiationStarter implements IOEventHandlerFactory
101
104
this .http1ConnectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy : DefaultClientConnectionReuseStrategy .INSTANCE ;
102
105
this .http1ResponseParserFactory = new DefaultHttpResponseParserFactory (h1Config );
103
106
this .http1RequestWriterFactory = DefaultHttpRequestWriterFactory .INSTANCE ;
107
+ this .exceptionCallback = exceptionCallback ;
104
108
}
105
109
106
110
@ Override
@@ -257,12 +261,12 @@ public void onOutputFlowControl(final HttpConnection connection, final int strea
257
261
}
258
262
259
263
ioSession .registerProtocol (ApplicationProtocol .HTTP_1_1 .id , new ClientHttp1UpgradeHandler (http1StreamHandlerFactory ));
260
- ioSession .registerProtocol (ApplicationProtocol .HTTP_2 .id , new ClientH2UpgradeHandler (http2StreamHandlerFactory ));
264
+ ioSession .registerProtocol (ApplicationProtocol .HTTP_2 .id , new ClientH2UpgradeHandler (http2StreamHandlerFactory , exceptionCallback ));
261
265
262
266
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy ) attachment : HttpVersionPolicy .NEGOTIATE ;
263
267
switch (versionPolicy ) {
264
268
case FORCE_HTTP_2 :
265
- return new ClientH2PrefaceHandler (ioSession , http2StreamHandlerFactory , false );
269
+ return new ClientH2PrefaceHandler (ioSession , http2StreamHandlerFactory , false , exceptionCallback );
266
270
case FORCE_HTTP_1 :
267
271
return new ClientHttp1IOEventHandler (http1StreamHandlerFactory .create (ioSession ));
268
272
default :
0 commit comments