Apache HttpClient 4.3 SocketConfig.getSoTimeout() 与 RequestConfig.getSocketTimeout() [英] Apache HttpClient 4.3 SocketConfig.getSoTimeout() vs RequestConfig.getSocketTimeout()

查看:38
本文介绍了Apache HttpClient 4.3 SocketConfig.getSoTimeout() 与 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆