Ignore:
Timestamp:
Feb 6, 2009 7:56:09 AM (15 years ago)
Author:
bennylp
Message:

Allow SIP messages in mod_sendto.py to insert fields (ticket #707)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/tests/pjsua/inc_sip.py

    r2110 r2440  
    9292                        print str(time.strftime("%H:%M:%S ")) + txt 
    9393 
    94         def create_req(self, method, sdp, branch="", extra_headers=""): 
    95                 if branch=="": 
    96                         self.cseq = self.cseq + 1 
    97                 msg = req_templ 
    98                 msg = msg.replace("$METHOD", method) 
     94        def update_fields(self, msg): 
    9995                if self.tcp: 
    10096                        transport_param = ";transport=tcp" 
     
    104100                msg = msg.replace("$LOCAL_IP", self.local_ip) 
    105101                msg = msg.replace("$LOCAL_PORT", str(self.local_port)) 
    106                 if branch=="": 
    107                         branch=str(random.random()) 
    108                 msg = msg.replace("$BRANCH", branch) 
    109102                msg = msg.replace("$FROM_TAG", self.local_tag) 
    110103                msg = msg.replace("$TO_TAG", self.rem_tag) 
    111104                msg = msg.replace("$CALL_ID", self.call_id) 
    112105                msg = msg.replace("$CSEQ", str(self.cseq)) 
     106                branch=str(random.random()) 
     107                msg = msg.replace("$BRANCH", branch) 
     108                return msg 
     109 
     110        def create_req(self, method, sdp, branch="", extra_headers=""): 
     111                if branch=="": 
     112                        self.cseq = self.cseq + 1 
     113                msg = req_templ 
     114                msg = msg.replace("$METHOD", method) 
    113115                msg = msg.replace("$SIP_HEADERS", extra_headers) 
     116                if branch=="": 
     117                        branch=str(random.random()) 
     118                msg = msg.replace("$BRANCH", branch) 
    114119                if sdp!="": 
    115120                        msg = msg.replace("$CONTENT_LENGTH", str(len(sdp))) 
     
    119124                msg = msg + "\r\n" 
    120125                msg = msg + sdp 
    121                 return msg 
     126                return self.update_fields(msg) 
    122127 
    123128        def create_response(self, request, code, reason, to_tag=""): 
Note: See TracChangeset for help on using the changeset viewer.