Is there a way to see what the current value and change it for the socket buffer size used by Apache Http Client?

时光怂恿深爱的人放手 提交于 2019-12-13 20:32:00

问题


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?


回答1:


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.

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();


来源:https://stackoverflow.com/questions/21946631/is-there-a-way-to-see-what-the-current-value-and-change-it-for-the-socket-buffer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!