4040import org .asynchttpclient .org .jboss .netty .handler .codec .http .CookieDecoder ;
4141import org .asynchttpclient .providers .netty .Callback ;
4242import org .asynchttpclient .providers .netty .NettyAsyncHttpProviderConfig ;
43- import org .asynchttpclient .providers .netty .NettyAsyncHttpProviderConfig .ResponseBodyPartFactory ;
4443import org .asynchttpclient .providers .netty .channel .Channels ;
4544import org .asynchttpclient .providers .netty .future .NettyResponseFuture ;
4645import org .asynchttpclient .providers .netty .request .NettyRequestSender ;
@@ -54,14 +53,20 @@ public abstract class Protocol {
5453
5554 protected final Channels channels ;
5655 protected final AsyncHttpClientConfig config ;
56+ protected final NettyAsyncHttpProviderConfig nettyConfig ;
5757 protected final NettyRequestSender requestSender ;
58- protected final ResponseBodyPartFactory bodyPartFactory ;
58+
59+ private final boolean hasResponseFilters ;
60+ protected final boolean hasIOExceptionFilters ;
5961
6062 public Protocol (Channels channels , AsyncHttpClientConfig config , NettyAsyncHttpProviderConfig nettyConfig , NettyRequestSender requestSender ) {
6163 this .channels = channels ;
6264 this .config = config ;
6365 this .requestSender = requestSender ;
64- this .bodyPartFactory = nettyConfig .getBodyPartFactory ();
66+ this .nettyConfig = nettyConfig ;
67+
68+ hasResponseFilters = !config .getResponseFilters ().isEmpty ();
69+ hasIOExceptionFilters = !config .getIOExceptionFilters ().isEmpty ();
6570 }
6671
6772 public abstract void handle (Channel channel , NettyResponseFuture <?> future , Object message ) throws Exception ;
@@ -154,7 +159,7 @@ public void call() throws Exception {
154159 protected boolean handleResponseFiltersReplayRequestAndExit (Channel channel , NettyResponseFuture <?> future , HttpResponseStatus status , HttpResponseHeaders responseHeaders )
155160 throws IOException {
156161
157- if (! config . getResponseFilters (). isEmpty () ) {
162+ if (hasResponseFilters ) {
158163 AsyncHandler <?> handler = future .getAsyncHandler ();
159164 FilterContext fc = new FilterContext .FilterContextBuilder ().asyncHandler (handler ).request (future .getRequest ()).responseStatus (status ).responseHeaders (responseHeaders )
160165 .build ();
0 commit comments