기본 콘텐츠로 건너뛰기

6월, 2015의 게시물 표시

Apache HttpClient Example

HttpGet httpGet = new HttpGet(imageUrl); try {     RequestConfig requestConfig = RequestConfig.custom()             .setSocketTimeout(HTTP_TIME_OUT)             .setConnectTimeout(HTTP_TIME_OUT)             .setConnectionRequestTimeout(HTTP_TIME_OUT)             .build();     CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();     HttpResponse response= client.execute(httpGet);     if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {         throw new ValidationException("not found image");     } } catch (ValidationException ve) {     throw ve; } catch (Exception e) {     log.warn(e.getMessag...