// by a Proxy, then the proxy will take care of stripping the
// Route header. If the request is being processed by an
// endpoint, then the stack strips off the route header.
if (sipRequest.getHeader(Route.NAME) != null
&& transaction.getDialog() != null) {
final RouteList routes = sipRequest.getRouteHeaders();
final Route route = (Route) routes.getFirst();
final SipUri uri = (SipUri) route.getAddress().getURI();
final HostPort hostPort = uri.getHostPort();
int port;
if (hostPort.hasPort()) {
port = hostPort.getPort();
} else {
if (listeningPoint.getTransport().equalsIgnoreCase(
ListeningPoint.TLS))
port = 5061;
else
port = 5060;
}
String host = hostPort.getHost().encode();
if ((host.equals(listeningPoint.getIPAddress()) || host
.equalsIgnoreCase(listeningPoint.getSentBy()))
&& port == listeningPoint.getPort()) {
if (routes.size() == 1)
sipRequest.removeHeader(Route.NAME);
else
routes.removeFirst();
}
}
final String sipRequestMethod = sipRequest.getMethod();
if (sipRequestMethod.equals(Request.REFER) && dialog != null
&& sipProvider.isDialogErrorsAutomaticallyHandled()) {