我尝试用这个简单的代码在 Android 上执行一个简单的 http 请求:
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
return EntityUtils.toString(httpEntity);
在我测试的每台设备上,它都可以正常工作(Android 2.3.6 +),但是我今天测试的 HTC Desire(Android 2.3.5)因超时而失败。但这仅发生在我的特定网址上,如下所示:
http://api.mydomain.com/some/path/index.php?param=value+number¶m2=value
如果我尝试另一个网址,例如:
http://www.google.com
它可以工作,即使在 HTC 上也是如此。有没有人知道,为什么我只在这些设备/网址上超时?