response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
// create exchange and set data on it
Exchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
if (consumer.getEndpoint().isBridgeEndpoint()) {
exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
}
if (consumer.getEndpoint().isDisableStreamCache()) {
exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
}
// we override the classloader before building the HttpMessage just in case the binding
// does some class resolution
ClassLoader oldTccl = overrideTccl(exchange);
HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
exchange.setIn(new HttpMessage(exchange, request, response));
// set context path as header
String contextPath = consumer.getEndpoint().getPath();
exchange.getIn().setHeader("CamelServletContextPath", contextPath);
String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH);
// here we just remove the CamelServletContextPath part from the HTTP_PATH
if (contextPath != null
&& httpPath.startsWith(contextPath)) {
exchange.getIn().setHeader(Exchange.HTTP_PATH,
httpPath.substring(contextPath.length()));
}
// we want to handle the UoW
try {
consumer.createUoW(exchange);
} catch (Exception e) {
log.error("Error processing request", e);
throw new ServletException(e);
}
try {
if (log.isTraceEnabled()) {
log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
}
// process the exchange
consumer.getProcessor().process(exchange);
} catch (Exception e) {
exchange.setException(e);
}
try {
// now lets output to the response
if (log.isTraceEnabled()) {
log.trace("Writing response for exchangeId: {}", exchange.getExchangeId());
}
Integer bs = consumer.getEndpoint().getResponseBufferSize();
if (bs != null) {
log.trace("Using response buffer size: {}", bs);
response.setBufferSize(bs);