public static InputStream getGzipStreamWithTimeout(String url) throws Exception {
InputStream instream=null;
HttpParams my_httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(my_httpParams,5000);
HttpConnectionParams.setSoTimeout(my_httpParams,5000);
HttpClient httpClient = new DefaultHttpClient(my_httpParams);
HttpUriRequest request = new HttpGet(url);
try{
HttpResponse response = httpClient.execute(request);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
return null;
}
instream = response.getEntity().getContent();
return instream;
}
No comments:
Post a Comment