Apache HttpClient 4.3 SocketConfig.getSoTimeout()与RequestConfig.getSocketTimeout() [英] Apache HttpClient 4.3 SocketConfig.getSoTimeout() vs RequestConfig.getSocketTimeout()
问题描述
在Apache HttpClient 4.3中构建CloseableHttpClient
时,我可以使用
When building a CloseableHttpClient
in Apache HttpClient 4.3, I can use
SocketConfig.custom().setSoTimeout(soTimeout).build()
并将其发送到我的连接管理器的setDefaultSocketConfig()
方法.
and send it to the setDefaultSocketConfig()
method of my connection manager.
我也可以使用
RequestConfig.custom().setSocketTimeout(socketTimeout).build()
并将其发送到我的http客户端构建器的setDefaultRequestConfig()
方法.
and send it to the setDefaultRequestConfig()
method of my http client builder.
这些药物会产生相同的最终结果还是不同的最终结果?
Will these have the same end effect or different end effects?
推荐答案
SocketConfig
中的套接字超时代表应用于新创建的连接的默认值.通过在RequestConfig
中设置套接字超时的非零值,可以为单个请求覆盖该值.
Socket timeout in SocketConfig
represents the default value applied to newly created connections. This value can be overwritten for individual requests by setting a non zero value of socket timeout in RequestConfig
.
这篇关于Apache HttpClient 4.3 SocketConfig.getSoTimeout()与RequestConfig.getSocketTimeout()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!