in src/main/java/com/epam/dep/esp/common/web/Web.java [200:230]
protected String performRequest(HttpClientContext context, HttpRequestBase httpRequest) throws IOException {
CloseableHttpResponse response = httpClient.execute(httpRequest, context);
if (logger.isInfoEnabled()) {
logger.info("Request to {}", httpRequest);
logger.info("Response {}", response.getStatusLine());
}
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream inStream = entity.getContent();
try (InputStreamReader isr = new InputStreamReader(inStream)) {
int numCharsRead;
char[] charArray = new char[1024];
StringBuilder sb = new StringBuilder();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 300) {
throw new WebToolsException("Response code is " + statusCode + " result: " + sb.toString());
}
return sb.toString();
} finally {
inStream.close();
}
}
return null;
} finally {
response.close();
}
}