0

How to set the timeout for HTTP multipart file post. I want to upload image to the server at the time internet connection is not there how to handle that situation?

4

1 回答 1

0

最后我找到了解决方案,这里是为 HTTPClient 设置超时的代码

HttpParams httpParameters = new BasicHttpParams();

int timeoutConnection = 30000; HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection);

int timeoutSocket = 30000;

HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

HttpClient httpClient = new DefaultHttpClient(httpParameters);

于 2012-06-06T05:31:45.407 回答