问题描述
我正在使用 Apache HttpClient 4.3.x,想知道是否有办法查看它用于发送/接收数据的套接字缓冲区大小的当前值,以及我是否可以更改它?
I'm using Apache HttpClient 4.3.x and was wondering if there's a way too see what is the current value for the socket buffer size used by it to send/receive data and if it's possible for me to change it?
推荐答案
我还没有找到查看当前值的方法,但是如果您在构建 ConnectionConfig
>HttpClient,它使用 ConnectionConfig.DEFAULT
,它的 bufferSize
为 8192
.
I have not found a way to see the current value, but if you haven't provided a ConnectionConfig
when building your HttpClient
, it uses ConnectionConfig.DEFAULT
which has a bufferSize
of 8192
.
您可以在构建 HttpClient
时指定自定义缓冲区大小.例如,
You can specify a custom buffer size when building your HttpClient
. For example,
int bufferSize = 42;
ConnectionConfig config = ConnectionConfig.custom().setBufferSize(bufferSize).build();
CloseableHttpClient httpClient = HttpClientBuilder.create()
.setDefaultConnectionConfig(config)
.build();
这篇关于有没有办法查看当前值并将其更改为 Apache Http 客户端使用的套接字缓冲区大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!