httpContext = ensureContext(httpContext);
applyAuthentication(asAbstractClient(httpClient), url, httpContext, authenticator);
HttpResponse response = httpClient.execute(request, httpContext);
// Response
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (HttpSC.isClientError(statusCode) || HttpSC.isServerError(statusCode)) {
log.debug(format("[%d] %s %s", id, statusLine.getStatusCode(), statusLine.getReasonPhrase()));
// Error responses can have bodies so it is important to clear
// up.
EntityUtils.consume(response.getEntity());
throw new HttpException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
}
// Redirects are followed by HttpClient.
if (handler != null)
handler.handle(baseURI, response);
} catch (IOException ex) {