Permalink
Browse files

fix post hangup url in outbound socket

  • Loading branch information...
1 parent fedfad3 commit ca5f5d4de22837797cc7df2bee7d4be2bc37f5fb @tamiel tamiel committed May 18, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/plivo/rest/freeswitch/outbound_socket.py
@@ -77,7 +77,7 @@ def __init__(self, socket, address, log,
self.target_url = ""
self.hangup_url = ""
self.direction = ""
- self.session_params = None
+ self.session_params = {}
self._action_queue = gevent.queue.Queue()
self.default_answer_url = default_answer_url
self.default_hangup_url = default_hangup_url
@@ -139,7 +139,7 @@ def on_channel_hangup(self, event):
if hangup_url:
self.session_params['hangup_cause'] = self._hangup_cause
self.log.info("Posting hangup to %s" % hangup_url)
- self.post_to_url(hangup_url, params)
+ self.post_to_url(hangup_url)
def on_channel_hangup_complete(self, event):
if not self._hangup_cause:
@@ -293,16 +293,17 @@ def post_to_url(self, url=None, params={}, method='POST'):
This method will do an http POST or GET request to the Url
"""
if not url:
+ self.log.warn("Cannot post, no url !")
return None
- params = params.update(self.session_params)
+ params.update(self.session_params)
http_obj = HTTPRequest(self.auth_id, self.auth_token)
try:
data = http_obj.fetch_response(url, params, method)
- self.log.info("Posted to %s with %s -- Result: %s"
+ self.log.info("Posted to %s with %s -- Result: %s" \
% (url, params, data))
return data
except Exception, e:
- self.log.error("Post to %s with %s -- Error: %s"
+ self.log.error("Post to %s with %s -- Error: %s" \
% (url, params, e))
return None
@@ -380,3 +381,4 @@ def execute_xml(self):
self.answer()
self.answered = True
grammar_element.run(self)
+

0 comments on commit ca5f5d4

Please sign in to comment.