如何拦截 Apache AsyncHttpClient 中的请求?

How to intercept a request in Apache AsyncHttpClient?

有没有办法拦截AsyncHttpClient发出的请求,并根据请求数据做一些操作

我想做这样的事情:

    interceptor = new Interceptor(){
        process(request){
           //do something  
        }
    }
    
    client.addInterceptor(interceptor);

这样的事情可能吗?

我用 'filters'.

做到了
AsyncHttpClientConfig.Builder configBuilder = new AsyncHttpClientConfig.Builder();
configBuilder.addResponseFilter(new ResponseFilter() {
    public FilterContext filter(FilterContext ctx) throws FilterException {
              //do something
        }
    }
});
AsyncHttpClient c = new AsyncHttpClient(configBuilder.build());

同样你可以添加一个请求过滤器

configbuilder.addRequestFilter(RequestFilterImpl);