本文介绍了有没有办法查看当前值并将其更改为Apache Http Client使用的套接字缓冲区大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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?

推荐答案

我还没有找到查看当前值的方法,但是如果在构建HttpClient时未提供ConnectionConfig,它将使用ConnectionConfig.DEFAULTbufferSize8192.

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 Client使用的套接字缓冲区大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 15:39