//header.
//If the new URI is again referring to a resource in the server to which the original request
//is sent, then replace the hostname and port of the URI with the hostname and port of synapse
//We are not changing the request url here, only the host name and the port.
try {
URI serviceURI = new URI(servicePrefix);
URI endpointURI = new URI(endpointURLPrefix);
URI locationURI = new URI(header.getValue());
if (locationURI.getHost().equalsIgnoreCase(endpointURI.getHost())) {
URI newURI = new URI(locationURI.getScheme(), locationURI.getUserInfo(),
serviceURI.getHost(), serviceURI.getPort(), locationURI.getPath(),
locationURI.getQuery(), locationURI.getFragment());
headerMap.put(header.getName(), newURI.toString());
responseMsgCtx.setProperty(NhttpConstants.SERVICE_PREFIX,
outMsgCtx.getProperty(NhttpConstants.SERVICE_PREFIX));
}
} catch (URISyntaxException e) {
log.error(e.getMessage(), e);