1

我不知道 HttpClient 究竟是如何工作的,但我觉得很奇怪,如果我用初始化 httpclient 会收到内部服务器错误,new DefaultHttpClient(httpParameters)但如果我用new DefaultHttpClient(). 我还应该提到,第一次请求时不会发生错误。这是我的一段代码,有什么错误吗?

HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
HttpClient httpclient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpclient.execute(new HttpGet(url));
int statusCode = response.getStatusLine().getStatusCode();
4

1 回答 1

1

尝试改变

HttpClient httpclient 

DefaultHttpClient httpclient
于 2012-10-26T18:52:40.377 回答