<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hey Alex,<div class=""><br class=""></div><div class="">Thanks, that does make a lot of sense. I’ve certainly gotten myself into some situations before using the powerful and dangerous toolset that is Kamailio! I will look into the PBX doing this, however it’s a bit tricky, as it’s not aware of the specific requirements of the next hop, or even what the next hop is.</div><div class=""><br class=""></div><div class="">Regardless though, I’m not completely sure if the location of the Content-Length header is the issue here. I’ve manipulated both Content-Type and Content-Length to the bottom of the headers with the following code just to see if this does solve the problem, and it doesn’t appear to:</div><div class=""><br class=""></div><div class=""><div style="background-color: rgb(30, 30, 30); line-height: 18px;" class=""><div class=""><font color="#d4d4d4" style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre;" class="">  replace_contact_header(</font><font color="#ce9178" face="Menlo, Monaco, Courier New, monospace" class=""><span style="caret-color: rgb(206, 145, 120); white-space: pre;" class="">“</span></font><span style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(206, 145, 120);" class=""><</span><font color="#569cd6" style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre;" class=""><span style="caret-color: rgb(86, 156, 214);" class=""><a href="sip:61400123123@kamailio" class="">sip:61400123123@kamailio</a>.test.uconnected.com.au</span></font><span style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(206, 145, 120);" class="">>"</span><font color="#d4d4d4" style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre;" class="">)</font></div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  cl = <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">PV</span>.gete(<span style="color: #ce9178;" class="">"$cl"</span>)</div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  cT = <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">PV</span>.gete(<span style="color: #ce9178;" class="">"$cT"</span>)</div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.remove(<span style="color: #ce9178;" class="">"Content-Type"</span>) <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.is_present(<span style="color: #ce9178;" class="">'Content-Type'</span>) > <span style="color: #b5cea8;" class="">0</span></div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.append(<span style="color: #ce9178;" class="">"Content-Type: </span><span style="color: #569cd6;" class="">#{</span>cT<span style="color: #569cd6;" class="">}</span><span style="color: #d7ba7d;" class="">\r\n</span><span style="color: #ce9178;" class="">"</span>)  </div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.remove(<span style="color: #ce9178;" class="">"Content-Length"</span>) <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.is_present(<span style="color: #ce9178;" class="">'Content-Length'</span>) > <span style="color: #b5cea8;" class="">0</span></div><div style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; color: rgb(212, 212, 212);" class="">  <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.append(<span style="color: #ce9178;" class="">"Content-Length: </span><span style="color: #569cd6;" class="">#{</span>cl<span style="color: #569cd6;" class="">}</span><span style="color: #d7ba7d;" class="">\r\n</span><span style="color: #ce9178;" class="">"</span>)  </div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" size="1" class="">Record-Route: <<a href="sip:1.2.3.4;lr;ftag=e4ZXUgGac1e8K;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAVd93nfAEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=923.76f1" class="">sip:1.2.3.4;lr;ftag=e4ZXUgGac1e8K;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAVd93nfAEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=923.76f1</a>></font></div><div class=""><font face="Courier New" size="1" class="">...</font></div><div class=""><font face="Courier New" size="1" class="">Call-ID: 814ec57f-e433-83ca-6d8e-023563fb337c</font></div><div class=""><font face="Courier New" size="1" class="">CSeq: 17740239 INVITE</font></div><div class=""><font face="Courier New" size="1" class=""><a href="sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Contact:" class="">sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Contact:</a> <sip<a href="sip:61400123123@kamailio.test.uconnected.com.au" class="">:61400123123@kamailio.test.uconnected.com.au</a>></font></div><div class=""><font face="Courier New" size="1" class="">Content-Type: application/sdp</font></div><div class=""><font face="Courier New" size="1" class="">Content-Length: 483</font></div></div><div class=""><br class=""></div><div class="">Given this is now in line with RFC location of the Content-Length, doesn’t this indicate an issue beyond correct placement of this header? It still seems like the Contact header is still being removed incorrect by the function.</div><div class=""><br class=""></div><div class="">FYI I ran a test call with just the <span style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30); color: rgb(78, 201, 176);" class="">KSR</span><span style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);" class="">::</span><span style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30); color: rgb(78, 201, 176);" class="">HDR</span><span style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);" class="">.remove(</span><span style="font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30); color: rgb(206, 145, 120);" class="">"Contact"</span><span style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);" class="">)</span> call, and still saw the issue:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" size="1" class="">Record-Route: <<a href="sip:1.2.3.4;lr;ftag=j8428v06y47jj;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQGfdDfEGEAEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=ead.25c1" class="">sip:1.2.3.4;lr;ftag=j8428v06y47jj;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQGfdDfEGEAEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=ead.25c1</a>></font></div><div class=""><font face="Courier New" size="1" class="">Call-ID: 0e349984-b83a-1238-6d8e-023563fb337c</font></div><div class=""><font face="Courier New" size="1" class="">CSeq: 17740572 INVITE</font></div><div class=""><font face="Courier New" size="1" class=""><a href="sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type:" class="">sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type:</a> application/scp</font></div><div class=""><font face="Courier New" size="1" class="">Content-Length: 483</font></div></div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Andrew</div><div><br class=""><blockquote type="cite" class=""><div class="">On 19 Mar 2020, at 2:01 pm, Alex Balashov <<a href="mailto:abalashov@evaristesys.com" class="">abalashov@evaristesys.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Andrew,<br class=""><br class="">On Thu, Mar 19, 2020 at 01:53:53PM +1100, Andrew White wrote:<br class=""><br class=""><blockquote type="cite" class="">The substitute and arbitrary position options look useful. In these<br class="">cases, will Kamailio automatically recalculate the Content-Length, or<br class="">do I need to manually rewrite this somehow?<br class=""></blockquote><br class="">The Content-Length pertains to the length of an (optional) encapsulated<br class="">message body only, and not to the length of the SIP message as such, and<br class="">therefore does not apply to any of its headers. <br class=""><br class="">Encapsulated bodies are used to transport messages of another protocol<br class="">inside SIP. In SIP land, the most common encapsulated payload is the SDP<br class="">payload, e.g.<br class=""><br class="">   ...<br class="">   Content-Type: application/sdp<br class="">   Content-Length: xxx<br class=""><br class="">   [SDP of length xxx goes here]<br class=""><br class="">If an encapsulated body is not present, Content-Length is still<br class="">mandatory but must be set to 0. <br class=""><br class=""><blockquote type="cite" class="">I did read that in researching before emailing, from similar thread<br class="">you responded to about 5 years ago! In this case, we have a specific<br class="">upstream provider who reject our Contact header in the normal format<br class="">we send, and require it to be in a specific format. As such, I can<br class="">manipulate the header on our PBX or on Kamailio. Given Kamailio is<br class="">aware of the provider we’re sending to and the PBX is not, it seems<br class="">simpler to do on Kamailio.<br class=""></blockquote><br class="">The problem with that philosophy is that Contact is fundamentally a<br class="">creature of the user agent, not of the proxy, so the proxy shouldn't be<br class="">manipulating it. Any time you manipulate it, you run the risk that a<br class="">message reliant on that value will be sent in the other direction (the<br class="">PBX), and the PBX says, "What?! That's not what I sent!" If that<br class="">happens, you rapidly descend into an unmanageable hellscape of stateful<br class="">management of this value so as to fool the PBX into thinking that you<br class="">didn't change it, and so forth. <br class=""><br class="">This should really be done on the calling UA if at all possible. Ideally<br class="">you could somehow tweak the PBX to send the value in the desired format<br class="">to begin with.<br class=""><br class="">Kamailio provides a lot of tools to shoot onesself in the foot with. It<br class="">makes things technically possible that shouldn't necessarily be done<br class="">just because they are possible. IMHO. :-)<br class=""><br class="">-- Alex<br class=""><br class="">-- <br class="">Alex Balashov | Principal | Evariste Systems LLC<br class=""><br class="">Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)<br class="">Web: <a href="http://www.evaristesys.com/" class="">http://www.evaristesys.com/</a>, <a href="http://www.csrpswitch.com/" class="">http://www.csrpswitch.com/</a><br class=""><br class="">_______________________________________________<br class="">Kamailio (SER) - Users Mailing List<br class=""><a href="mailto:sr-users@lists.kamailio.org" class="">sr-users@lists.kamailio.org</a><br class="">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users<br class=""></div></div></blockquote></div><br class=""></body></html>