latch.await();
}
public boolean process(final Exchange exchange, final AsyncCallback callback) {
ContentExchange jettyExchange = new CamelContentExchange(exchange, callback);
jettyExchange.setURL(address);
// If a in body can be converted to an InputStream or a Buffer
// then do a POST otherwise, do a GET
Message in = exchange.getIn();
InputStream is = in.getBody(InputStream.class);
if (is != null) {
jettyExchange.setMethod(HttpMethods.POST);
jettyExchange.setRequestContentSource(is);
} else {
Buffer buffer = in.getBody(Buffer.class);
if (buffer != null) {
jettyExchange.setMethod(HttpMethods.POST);
jettyExchange.setRequestContent(buffer);
} else {
jettyExchange.setMethod(HttpMethods.GET);
}
}
// propagate headers to http request
HeaderFilterStrategy strategy = ((HttpEndpoint)getEndpoint()).getHeaderFilterStrategy();
for (String name : in.getHeaders().keySet()) {
String value = in.getHeader(name, String.class);
if ("Content-Type".equals(name)) {
jettyExchange.setRequestContentType(value);
} else if (strategy != null && !strategy.applyFilterToCamelHeaders(name, value)) {
jettyExchange.addRequestHeader(name, value);
}
}
try {
httpClient.send(jettyExchange);