Skip to content

Commit

Permalink
handle header folding, add rport for tcp, and some more debug trace
Browse files Browse the repository at this point in the history
  • Loading branch information
theintencity committed Sep 4, 2012
1 parent 649abf4 commit baf3b85
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/std/rfc3261.py
Original file line number Diff line number Diff line change
@@ -250,10 +250,15 @@ def _parse(self, value):
except: # probably a request
self.method, self.uri, self.protocol = a, URI(b), c

hlist = []
for h in headers.split('\n'):
if h and h[-1] == '\r': h = h[:-1]
if h.startswith(r'[ \t]'):
pass
if h and (h[0] == ' ' or h[0] == '\t'):
if hlist:
hlist[-1] += h
else:
hlist.append(h)
for h in hlist:
try:
name, values = Header.createHeaders(h)
if name not in self: # doesn't already exist
@@ -478,6 +483,9 @@ def received(self, data, src):
if 'rport' in via:
via['rport'] = src[1]
via.viaUri.port = src[1]
if self.transport.type == 'tcp': # assume rport
via['rport'] = src[1]
via.viaUri.port = src[1]
if self.fix_nat and m.method in ('INVITE', 'MESSAGE'):
self._fixNatContact(m, src)
self._receivedRequest(m, uri)
@@ -1252,6 +1260,7 @@ def sendCancel(self):
def timeout(self, transaction):
'''A client transaction was timedout.'''
if transaction and transaction != self.transaction: # invalid transaction
if _debug: print 'invalid transaction in timeout() %r != %r'%(transaction, self.transaction)
return
self.transaction = None
if not self.server: # UAC

0 comments on commit baf3b85

Please sign in to comment.