summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-02-06 07:56:09 +0000
committerBenny Prijono <bennylp@teluu.com>2009-02-06 07:56:09 +0000
commiteec6d8991f9a3323cfbf76672d8825c22f196b79 (patch)
tree15c8849b52984e8b5ad39fc88be184b8acdc5859 /tests
parent868eb7a71dc1f48ee0c62fceec2da449c4b0795b (diff)
Allow SIP messages in mod_sendto.py to insert fields (ticket #707)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2440 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'tests')
-rw-r--r--tests/pjsua/inc_sip.py23
-rw-r--r--tests/pjsua/mod_sendto.py2
2 files changed, 15 insertions, 10 deletions
diff --git a/tests/pjsua/inc_sip.py b/tests/pjsua/inc_sip.py
index 6d5ef052..0c05756f 100644
--- a/tests/pjsua/inc_sip.py
+++ b/tests/pjsua/inc_sip.py
@@ -91,11 +91,7 @@ class Dialog:
if self.trace_enabled:
print str(time.strftime("%H:%M:%S ")) + txt
- def create_req(self, method, sdp, branch="", extra_headers=""):
- if branch=="":
- self.cseq = self.cseq + 1
- msg = req_templ
- msg = msg.replace("$METHOD", method)
+ def update_fields(self, msg):
if self.tcp:
transport_param = ";transport=tcp"
else:
@@ -103,14 +99,23 @@ class Dialog:
msg = msg.replace("$TARGET_URI", "sip:"+self.dst_addr+":"+str(self.dst_port) + transport_param)
msg = msg.replace("$LOCAL_IP", self.local_ip)
msg = msg.replace("$LOCAL_PORT", str(self.local_port))
- if branch=="":
- branch=str(random.random())
- msg = msg.replace("$BRANCH", branch)
msg = msg.replace("$FROM_TAG", self.local_tag)
msg = msg.replace("$TO_TAG", self.rem_tag)
msg = msg.replace("$CALL_ID", self.call_id)
msg = msg.replace("$CSEQ", str(self.cseq))
+ branch=str(random.random())
+ msg = msg.replace("$BRANCH", branch)
+ return msg
+
+ def create_req(self, method, sdp, branch="", extra_headers=""):
+ if branch=="":
+ self.cseq = self.cseq + 1
+ msg = req_templ
+ msg = msg.replace("$METHOD", method)
msg = msg.replace("$SIP_HEADERS", extra_headers)
+ if branch=="":
+ branch=str(random.random())
+ msg = msg.replace("$BRANCH", branch)
if sdp!="":
msg = msg.replace("$CONTENT_LENGTH", str(len(sdp)))
msg = msg + "Content-Type: application/sdp\r\n"
@@ -118,7 +123,7 @@ class Dialog:
msg = msg.replace("$CONTENT_LENGTH", "0")
msg = msg + "\r\n"
msg = msg + sdp
- return msg
+ return self.update_fields(msg)
def create_response(self, request, code, reason, to_tag=""):
response = "SIP/2.0 " + str(code) + " " + reason + "\r\n"
diff --git a/tests/pjsua/mod_sendto.py b/tests/pjsua/mod_sendto.py
index 4cc12a41..a2f45212 100644
--- a/tests/pjsua/mod_sendto.py
+++ b/tests/pjsua/mod_sendto.py
@@ -19,7 +19,7 @@ def test_func(t):
cfg = cfg_file.sendto_cfg
if len(cfg.complete_msg) != 0:
- req = cfg.complete_msg
+ req = dlg.update_fields(cfg.complete_msg)
else:
req = dlg.create_invite(cfg.sdp, cfg.extra_headers)
resp = dlg.send_request_wait(req, 10)