* @return the string
*/
private static String extractStringFrom(final HttpResponse response)
{
final HttpEntity entity = response.getEntity();
final StatusLine status = response.getStatusLine();
InputStream stream = null;
ensureResponse(contentSizeIsValid(entity),
format("Response content has unexpected length [%s]", entity.getContentLength()),
status.getStatusCode(), status.getReasonPhrase());
try
{
stream = entity.getContent();
}
catch (final Exception exception)
{
throw new ResponseException("Error while opening response stream", status.getStatusCode(),
status.getReasonPhrase(), exception);
}
return readStringFrom(stream, ifFailureThenReportAbout(status));
}