// that a remote party sent, and include the same in the Contact header of the response.
if ("INVITE".equals(_method) || "REFER".equals(_method) ||
"SUBSCRIBE".equals(_method)) {
try {
// Check if Response has Record-Route headers
Address rrouteAddress = getAddressHeaderImpl(Header.RECORD_ROUTE);
SipURI sipuri = null;
if ((rrouteAddress != null) &&
rrouteAddress.getURI().isSipURI()) {
// 1. Use transport from top-most Record Route on the incoming Request
sipuri = (SipURI) rrouteAddress.getURI();
} else {
// 2. Use transport from Contact
URI remoteTarget = getAddressHeaderImpl("Contact").getURI();
if (remoteTarget.isSipURI()) {
sipuri = (SipURI) remoteTarget;
}
}
if ((sipuri != null) && (sipuri.getTransportParam() != null)) {
String transport = sipuri.getTransportParam();
Address contactAddress = response.getAddressHeaderImpl(Header.CONTACT);
if ((contactAddress != null) &&
contactAddress.getURI().isSipURI()) {
((SipURI) contactAddress.getURI()).setTransportParam(transport);
}
}
} catch (Exception e) {
// Should not happen, but consequences would be that the transport parameter is not set.
}