[英](apache httpclient) What is different thing in 3 code?
HttpClient client = new HttpClient();
//1
client.setConnectionTimeout(1000);
//2
client.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 1000);
//3
client.getHttpConnectionManager().getParams().setConnectionTimeout(1000);
I want to know the main difference between this things? 我想知道这件事之间的主要区别吗?
They are all the same 他们都是一样的
There is one HttpClientParams
object which is created in or provided to the constructor of HttpClient
and passed to the HttpConnectionManager
有一个HttpClientParams
其在创建或提供给的构造物体HttpClient
并传递给HttpConnectionManager
From there, the 3 ways are just a slightly different flows to setting the same parameter in the parameters object. 从那里开始,这三种方式在参数对象中设置相同参数的流程略有不同。
For such issues have a look at the JavaDoc for the setConnectionTimeout method and the other ones. 对于此类问题,请查看JavaDoc中的setConnectionTimeout方法和其他方法。 It is likely that some of them are deprecated/bad practice depending on the version you are using. 根据您使用的版本,其中某些可能已被弃用/不当使用。 As this is OpenSource you can also read the code and see for yourself what happens behind the scenes, this is the only way to know for sure. 由于这是OpenSource,因此您还可以阅读代码并亲自了解幕后发生的事情,这是唯一可以肯定的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.