}
public void process(Exchange exchange) throws Exception {
HttpMethod method = createMethod(exchange);
Message in = exchange.getIn();
HeaderFilterStrategy strategy = ((HttpEndpoint)getEndpoint()).getHeaderFilterStrategy();
// propagate headers as HTTP headers
for (String headerName : in.getHeaders().keySet()) {
String headerValue = in.getHeader(headerName, String.class);
if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue)) {
method.addRequestHeader(headerName, headerValue);
}
}
// lets store the result in the output message.
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing http " + method.getName() + " method: " + method.getURI().toString());
}
int responseCode = executeMethod(method);
if (LOG.isDebugEnabled()) {
LOG.debug("Http responseCode: " + responseCode);
}
if (responseCode >= 100 && responseCode < 300) {
Message answer = exchange.getOut(true);
answer.setHeaders(in.getHeaders());
answer.setHeader(HTTP_RESPONSE_CODE, responseCode);
answer.setBody(extractResponseBody(method, exchange));
// propagate HTTP response headers
Header[] headers = method.getResponseHeaders();
for (Header header : headers) {
String name = header.getName();
String value = header.getValue();
if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value)) {
answer.setHeader(name, value);
}
}
} else {
HttpOperationFailedException exception = null;