// resolve placeholders in uri
try {
uri = exchange.getContext().resolvePropertyPlaceholders(uri);
} catch (Exception e) {
throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uri, exchange, e);
}
// append HTTP_PATH to HTTP_URI if it is provided in the header
String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
if (path != null) {
if (path.startsWith("/")) {
URI baseURI;
String baseURIString = exchange.getIn().getHeader(Exchange.HTTP_BASE_URI, String.class);
try {
if (baseURIString == null) {
if (exchange.getFromEndpoint() != null) {
baseURIString = exchange.getFromEndpoint().getEndpointUri();
} else {
// will set a default one for it
baseURIString = "/";
}
}
baseURI = new URI(baseURIString);
String basePath = baseURI.getPath();
if (path.startsWith(basePath)) {
path = path.substring(basePath.length());
if (path.startsWith("/")) {
path = path.substring(1);
}
} else {
throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: cannot find the right HTTP_BASE_URI", exchange);
}
} catch (Throwable t) {
throw new RuntimeExchangeException("Cannot analyze the Exchange.HTTP_PATH header, due to: " + t.getMessage(), exchange, t);
}
}
if (path.length() > 0) {
// make sure that there is exactly one "/" between HTTP_URI and
// HTTP_PATH