我将 HttpParameters 设置为 HttpClient。
现在我想测试它们是否设置正确。其实我是这样做的:
public class MyHttpClient extends DefaultHttpClient {
public MyHttpClient(int tc, int ts) {
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is established.
int timeoutConnection = tc;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = ts;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
ClientConnectionManager mgr = this.getConnectionManager();
this.setParams(httpParameters);
}
}
并像这样创建它的实例:
public static MyHttpClient httpclient = new MyHttpClient(5000, 5000);
如何知道这是否真的有效。
我试过这个:
httpclient.getParams().toString();
我得到了这个作为输出:
org.apache.http.params.BasicHttpParams@40520f20
似乎是我设置的Default Params
但不是我设置的。