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.getMessage(), e);
} finally {
httpGet.releaseConnection();
}
댓글
댓글 쓰기