InputStream in = null;
try {
Future<Response> futurama = _httpClient.executeRequest(reqBuilder.build());
// First, see if we can get the answer without time out...
Response resp;
try {
resp = futurama.get(timeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
return failed(CallFailure.timeout(_server, startTime, System.currentTimeMillis()));
}
// and if so, is it successful?
int statusCode = resp.getStatusCode();
// one thing first: handle standard headers, if any?
handleHeaders(_server, resp, startTime);
// call ok?
if (!IOUtil.isHTTPSuccess(statusCode)) {
// if not, why not? Any well-known problems? (besides timeout that was handled earlier)
// then the default fallback
String msg = getExcerpt(resp, config.getMaxExcerptLength());
return failed(CallFailure.general(_server, statusCode, startTime, System.currentTimeMillis(), msg));
}
ContentType contentType = findContentType(resp, ContentType.JSON);
in = resp.getResponseBodyAsStream();
return new AHCEntryListResult<T>(_server, converter.convert(contentType, in));
} catch (Exception e) {
if (in != null) {
try {
in.close();