我们有以下代码,稍后将其替换为 HttpHead 方法,因为我们只需要拉回网页的标题信息。更改后,我们注意到,对于相同的网页集,平均而言,HttpHead 的返回时间比 HttpGet 的返回时间要长。正常吗?这里有什么问题?
HttpClient httpclient = new DefaultHttpClient();
// the time it takes to open TCP connection.
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, this.timeout);
// timeout when server does not send data.
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, this.timeout);
// the get method
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httphead);