}
}
protected HttpOperationFailedException populateHttpOperationFailedException(Exchange exchange, JettyContentExchange httpExchange,
int responseCode) throws IOException {
HttpOperationFailedException exception;
String uri = httpExchange.getUrl();
Map<String, String> headers = httpExchange.getHeaders();
String body = extractResponseBody(exchange, httpExchange);
if (responseCode >= 300 && responseCode < 400) {
String locationHeader = httpExchange.getResponseFields().getStringField("location");
if (locationHeader != null) {
exception = new HttpOperationFailedException(uri, responseCode, null, locationHeader, headers, body);
} else {
// no redirect location
exception = new HttpOperationFailedException(uri, responseCode, null, null, headers, body);
}
} else {
// internal server error (error code 500)
exception = new HttpOperationFailedException(uri, responseCode, null, null, headers, body);
}
return exception;
}