Skip to content

Commit

Permalink
Insert Path header into REGISTER if path is in Supported.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Jul 22, 2024
1 parent ac93e33 commit 9535f63
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sippy/StatefulProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def recvRequest(self, req):
via0 = SipVia()
via0.genBranch()
via1 = req.getHF('via')
if req.getMethod() == 'REGISTER':
self.insertPath(req)
req.insertHeaderBefore(via1, SipHeader(name = 'via', body = via0))
req.setTarget(self.destination)
print(req)
Expand All @@ -49,3 +51,16 @@ def recvRequest(self, req):
def recvResponse(self, resp):
resp.removeHeader(resp.getHF('via'))
self.global_config['_sip_tm'].sendResponse(resp)

def insertPath(self, req):
try:
supported = req.getHFBody('supported')
except IndexError: pass
else:
if 'path' in supported.caps:
mypath = SipHeader(name = 'path')
if req.countHFs('path') == 0:
self.appendHeader(mypath)
else:
path1 = req.getHF('path')
req.insertHeaderBefore(path1, mypath)

0 comments on commit 9535f63

Please sign in to comment.