resteasy-client里面和chunked transfer有关的设计
首先通过单元测试代码作为切入点进行查看:

.jpg)
.jpg)
上面两个测试,一个是测试ClientInvocationBuilder.setChunked()方法,另一个是测试ResteasyWebTarget.setChunked()方法。
区别是分别测试ResteasyWebTarget和ClientInvocationBuilder。
以下是resteasy-client的设计架构:

可以看到里面核心的接口包括:
ClientBuilderInvocationWebTarget
然后resteasy针对这些jax-rs标准接口进行实现。其中ClientWebTarget和ClientInvocationBuilder都包含setChunked()方法。
其中ClientWebTarget里面的setChunked()方法直接设置自己的chunked属性:

然后在request()方法里传递给它包含的ClientInvocationBuilder:

ClientInvocationBuilder里面的setChunked()方法是调用ClientWebTarget的setChunked()方法:

然后ClientInvocation里面提供isChunked()方法:

查看这个方法被使用到的地方:

发现是ManualClosingApacheHttpClient43Engine:

使用chunked的方法是buildEnity():


进入查看entityToBuild.setChunked()方法:

可以看到实际使用这个chunked属性的是apache-client的AbstractHttpEntity。下面是相关class的关系全图:

通过以上的分析可以看到,实际使用chunked属性的是apache-httpclient,而resteasy这个层面只是起到了传递参数给底层apache-httpclient实现的作用。