HttpClient의 다른 버전 제한 시간 설정

자세히 보기
3. X 코드 예제:
HttpClient client=new DefaultHttpClient();
client.setConnectionTimeout(30000); 
client.setTimeout(30000);

 
4. X 코드의 예:
HttpClient httpClient=new DefaultHttpClient();
httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,2000);//    
httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,2000);//      
 
4.3 코드 예제:
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet=new HttpGet("http://www.baidu.com");//HTTP Get  (POST  )
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build();//           
httpGet.setConfig(requestConfig);
httpClient.execute(httpGet);//    
   

좋은 웹페이지 즐겨찾기