String newUrl;
if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
// its servlet based, so we need the servlet request
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
if (request == null) {
HttpMessage msg = exchange.getIn(HttpMessage.class);
if (msg != null) {
request = msg.getRequest();
}
}
if (request == null) {
throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a"
+ "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));