From ecd124dd068ea381555fca3c42c402c46da0cba1 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Thu, 22 Jan 2015 16:40:03 +0530 Subject: Boilerplate for xep_0332 --- sleekxmpp/plugins/xep_0332/http.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sleekxmpp/plugins/xep_0332/http.py (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py new file mode 100644 index 00000000..7b9628e3 --- /dev/null +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -0,0 +1,37 @@ +""" + SleekXMPP: The Sleek XMPP Library + Implementation of HTTP over XMPP transport + http://xmpp.org/extensions/xep-0332.html + Copyright (C) 2015 Riptide IO, sangeeth@riptideio.com + This file is part of SleekXMPP. + + See the file LICENSE for copying permission. +""" + +import logging + +from sleekxmpp.plugins.base import BasePlugin + + +log = logging.getLogger(__name__) + + +class XEP_0332(BasePlugin): + """ + XEP-0332: HTTP over XMPP transport + """ + + name = 'xep_0332' + description = 'XEP-0332: HTTP over XMPP transport' + dependencies = set(['xep_0030', 'xep_0047', 'xep_0131']) #: xep 1, 137 and 166 are missing + default_config = {} + + def plugin_init(self): + log.debug("XEP_0332:: plugin_init()") + + def plugin_end(self): + log.debug("XEP_0332:: plugin_end()") + + def session_bind(self, jid): + log.debug("XEP_0332:: session_bind()") + -- cgit v1.2.3 From e1f25604ecbf5d6c196080cd8394191c7ea459c9 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Wed, 28 Jan 2015 14:52:15 +0530 Subject: Added callbacks, registered stanzas, added features, etc. --- sleekxmpp/plugins/xep_0332/http.py | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 7b9628e3..f91cc1ff 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -10,8 +10,20 @@ import logging +from sleekxmpp import Iq + +from sleekxmpp.xmlstream import register_stanza_plugin +from sleekxmpp.xmlstream.handler import Callback +from sleekxmpp.xmlstream.matcher import StanzaPath + from sleekxmpp.plugins.base import BasePlugin +from sleekxmpp.plugins.xep_0332.stanza import NAMESPACE +from sleekxmpp.plugins.xep_0332.stanza.request import Request +from sleekxmpp.plugins.xep_0332.stanza.response import Response + +from sleekxmpp.plugins.xep_0131.stanza import Headers + log = logging.getLogger(__name__) @@ -29,9 +41,37 @@ class XEP_0332(BasePlugin): def plugin_init(self): log.debug("XEP_0332:: plugin_init()") + self.xmpp.register_handler(Callback( + 'HTTP Request', StanzaPath('iq/req'), self._handle_request + )) + self.xmpp.register_handler(Callback( + 'HTTP Response', StanzaPath('iq/resp'), self._handle_response + )) + + register_stanza_plugin(Iq, Request) + register_stanza_plugin(Iq, Response) + register_stanza_plugin(Request, Headers) + register_stanza_plugin(Response, Headers) + def plugin_end(self): log.debug("XEP_0332:: plugin_end()") + self.xmpp.remove_handler('HTTP Request') + self.xmpp.remove_handler('HTTP Response') + self.xmpp['xep_0030'].del_feature(NAMESPACE) def session_bind(self, jid): log.debug("XEP_0332:: session_bind()") + self.xmpp['xep_0030'].add_feature(NAMESPACE) + + def _handle_request(self): + log.debug("XEP_0332:: _handle_request()") + + def _handle_response(self): + log.debug("XEP_0332:: _handle_response()") + + def send_request(self, method=None, resource=None, headers=None, data=None, **kwargs): + log.debug("XEP_0332:: send_request()") + + def send_response(self, status_code=None, headers=None, data=None, **kwargs): + log.debug("XEP_0332:: send_response()") -- cgit v1.2.3 From a96f608469e74d39d3e7a2a86399dbb724ffadec Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Thu, 29 Jan 2015 08:33:40 +0530 Subject: Composing request and response. --- sleekxmpp/plugins/xep_0332/http.py | 94 ++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 19 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index f91cc1ff..166e6ec3 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -17,11 +17,7 @@ from sleekxmpp.xmlstream.handler import Callback from sleekxmpp.xmlstream.matcher import StanzaPath from sleekxmpp.plugins.base import BasePlugin - -from sleekxmpp.plugins.xep_0332.stanza import NAMESPACE -from sleekxmpp.plugins.xep_0332.stanza.request import Request -from sleekxmpp.plugins.xep_0332.stanza.response import Response - +from sleekxmpp.plugins.xep_0332.stanza import Request, Response, Data from sleekxmpp.plugins.xep_0131.stanza import Headers @@ -35,8 +31,23 @@ class XEP_0332(BasePlugin): name = 'xep_0332' description = 'XEP-0332: HTTP over XMPP transport' - dependencies = set(['xep_0030', 'xep_0047', 'xep_0131']) #: xep 1, 137 and 166 are missing - default_config = {} + + #: xep_0047 not included. + #: xep_0001, 0137 and 0166 are missing + dependencies = set(['xep_0030', 'xep_0131']) + + #: TODO: Do we really need to mention the supported_headers?! + default_config = { + 'supported_headers': set([ + 'Content-Length', 'Transfer-Encoding', 'DateTime', + 'Accept-Charset', 'Location', 'Content-ID', 'Description', + 'Content-Language', 'Content-Transfer-Encoding', 'Timestamp', + 'Expires', 'User-Agent', 'Host', 'Proxy-Authorization', 'Date', + 'WWW-Authenticate', 'Accept-Encoding', 'Server', 'Error-Info', + 'Identifier', 'Content-Location', 'Content-Encoding', 'Distribute', + 'Accept', 'Proxy-Authenticate', 'ETag', 'Expect', 'Content-Type' + ]) + } def plugin_init(self): log.debug("XEP_0332:: plugin_init()") @@ -48,30 +59,75 @@ class XEP_0332(BasePlugin): 'HTTP Response', StanzaPath('iq/resp'), self._handle_response )) - register_stanza_plugin(Iq, Request) - register_stanza_plugin(Iq, Response) - register_stanza_plugin(Request, Headers) - register_stanza_plugin(Response, Headers) + register_stanza_plugin(Iq, Request, iterable=True) + register_stanza_plugin(Iq, Response, iterable=True) + register_stanza_plugin(Request, Headers, iterable=True) + register_stanza_plugin(Request, Data, iterable=True) + register_stanza_plugin(Response, Headers, iterable=True) + register_stanza_plugin(Response, Data, iterable=True) + + # TODO: Should we register any api's here? self.api.register() def plugin_end(self): log.debug("XEP_0332:: plugin_end()") self.xmpp.remove_handler('HTTP Request') self.xmpp.remove_handler('HTTP Response') - self.xmpp['xep_0030'].del_feature(NAMESPACE) + self.xmpp['xep_0030'].del_feature('urn:xmpp:http') + for header in self.supported_headers: + self.xmpp['xep_0030'].del_feature( + feature='%s#%s' % (Headers.namespace, header) + ) def session_bind(self, jid): log.debug("XEP_0332:: session_bind()") - self.xmpp['xep_0030'].add_feature(NAMESPACE) - - def _handle_request(self): + self.xmpp['xep_0030'].add_feature('urn:xmpp:http') + for header in self.supported_headers: + self.xmpp['xep_0030'].add_feature( + '%s#%s' % (Headers.namespace, header) + ) + # TODO: Do we need to add the supported headers to xep_0131? + # self.xmpp['xep_0131'].supported_headers.add(header) + + def _handle_request(self, iq): log.debug("XEP_0332:: _handle_request()") + print iq - def _handle_response(self): + def _handle_response(self, iq): log.debug("XEP_0332:: _handle_response()") + print iq - def send_request(self, method=None, resource=None, headers=None, data=None, **kwargs): + def send_request(self, to=None, method=None, resource=None, headers=None, + data=None, **kwargs): log.debug("XEP_0332:: send_request()") - - def send_response(self, status_code=None, headers=None, data=None, **kwargs): + iq = self.xmpp.Iq() + iq['from'] = self.xmpp.boundjid + iq['to'] = to + iq['type'] = 'set' + iq['req']['headers'] = headers + iq['req']['method'] = method + iq['req']['resource'] = resource + iq['req']['version'] = '1.1' # TODO: set this implicitly + iq['req']['data'] = data + print iq + # return iq.send(timeout=kwargs.get('timeout', None), + # block=kwargs.get('block', True), + # callback=kwargs.get('callback', None), + # timeout_callback=kwargs.get('timeout_callback', None)) + + def send_response(self, to=None, code=None, headers=None, data=None, + **kwargs): log.debug("XEP_0332:: send_response()") + iq = self.xmpp.Iq() + iq['from'] = self.xmpp.boundjid + iq['to'] = to + iq['type'] = 'result' + iq['resp']['headers'] = headers + iq['resp']['code'] = code + iq['resp']['version'] = '1.1' # TODO: set this implicitly + iq['resp']['data'] = data + print iq + # return iq.send(timeout=kwargs.get('timeout', None), + # block=kwargs.get('block', True), + # callback=kwargs.get('callback', None), + # timeout_callback=kwargs.get('timeout_callback', None)) -- cgit v1.2.3 From c16b86220047e2a2b77c585d6b0d72f5087c1371 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Tue, 3 Feb 2015 12:33:25 +0530 Subject: Raise http_request and http_response events. --- sleekxmpp/plugins/xep_0332/http.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 166e6ec3..06ba1477 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -91,10 +91,12 @@ class XEP_0332(BasePlugin): def _handle_request(self, iq): log.debug("XEP_0332:: _handle_request()") print iq + self.xmpp.event('http_request', iq) def _handle_response(self, iq): log.debug("XEP_0332:: _handle_response()") print iq + self.xmpp.event('http_response', iq) def send_request(self, to=None, method=None, resource=None, headers=None, data=None, **kwargs): @@ -107,12 +109,13 @@ class XEP_0332(BasePlugin): iq['req']['method'] = method iq['req']['resource'] = resource iq['req']['version'] = '1.1' # TODO: set this implicitly - iq['req']['data'] = data + if data: + iq['req']['data'] = data print iq - # return iq.send(timeout=kwargs.get('timeout', None), - # block=kwargs.get('block', True), - # callback=kwargs.get('callback', None), - # timeout_callback=kwargs.get('timeout_callback', None)) + return iq.send(timeout=kwargs.get('timeout', None), + block=kwargs.get('block', True), + callback=kwargs.get('callback', None), + timeout_callback=kwargs.get('timeout_callback', None)) def send_response(self, to=None, code=None, headers=None, data=None, **kwargs): @@ -124,7 +127,8 @@ class XEP_0332(BasePlugin): iq['resp']['headers'] = headers iq['resp']['code'] = code iq['resp']['version'] = '1.1' # TODO: set this implicitly - iq['resp']['data'] = data + if data: + iq['resp']['data'] = data print iq # return iq.send(timeout=kwargs.get('timeout', None), # block=kwargs.get('block', True), -- cgit v1.2.3 From 8bc70264efd17390fbe795e359a7cbb0442fd0d1 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Thu, 5 Feb 2015 17:35:04 +0530 Subject: misc updates.. --- sleekxmpp/plugins/xep_0332/http.py | 62 +++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 06ba1477..36b6995f 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -50,26 +50,21 @@ class XEP_0332(BasePlugin): } def plugin_init(self): - log.debug("XEP_0332:: plugin_init()") - self.xmpp.register_handler(Callback( 'HTTP Request', StanzaPath('iq/req'), self._handle_request )) self.xmpp.register_handler(Callback( 'HTTP Response', StanzaPath('iq/resp'), self._handle_response )) - register_stanza_plugin(Iq, Request, iterable=True) register_stanza_plugin(Iq, Response, iterable=True) register_stanza_plugin(Request, Headers, iterable=True) register_stanza_plugin(Request, Data, iterable=True) register_stanza_plugin(Response, Headers, iterable=True) register_stanza_plugin(Response, Data, iterable=True) - # TODO: Should we register any api's here? self.api.register() def plugin_end(self): - log.debug("XEP_0332:: plugin_end()") self.xmpp.remove_handler('HTTP Request') self.xmpp.remove_handler('HTTP Response') self.xmpp['xep_0030'].del_feature('urn:xmpp:http') @@ -79,7 +74,6 @@ class XEP_0332(BasePlugin): ) def session_bind(self, jid): - log.debug("XEP_0332:: session_bind()") self.xmpp['xep_0030'].add_feature('urn:xmpp:http') for header in self.supported_headers: self.xmpp['xep_0030'].add_feature( @@ -89,18 +83,13 @@ class XEP_0332(BasePlugin): # self.xmpp['xep_0131'].supported_headers.add(header) def _handle_request(self, iq): - log.debug("XEP_0332:: _handle_request()") - print iq self.xmpp.event('http_request', iq) def _handle_response(self, iq): - log.debug("XEP_0332:: _handle_response()") - print iq self.xmpp.event('http_response', iq) def send_request(self, to=None, method=None, resource=None, headers=None, data=None, **kwargs): - log.debug("XEP_0332:: send_request()") iq = self.xmpp.Iq() iq['from'] = self.xmpp.boundjid iq['to'] = to @@ -109,29 +98,46 @@ class XEP_0332(BasePlugin): iq['req']['method'] = method iq['req']['resource'] = resource iq['req']['version'] = '1.1' # TODO: set this implicitly - if data: + if data is not None: iq['req']['data'] = data - print iq - return iq.send(timeout=kwargs.get('timeout', None), - block=kwargs.get('block', True), - callback=kwargs.get('callback', None), - timeout_callback=kwargs.get('timeout_callback', None)) - - def send_response(self, to=None, code=None, headers=None, data=None, - **kwargs): - log.debug("XEP_0332:: send_response()") + return iq.send( + timeout=kwargs.get('timeout', None), + block=kwargs.get('block', True), + callback=kwargs.get('callback', None), + timeout_callback=kwargs.get('timeout_callback', None) + ) + + def send_response(self, to=None, code=None, message=None, headers=None, + data=None, **kwargs): iq = self.xmpp.Iq() iq['from'] = self.xmpp.boundjid iq['to'] = to iq['type'] = 'result' iq['resp']['headers'] = headers iq['resp']['code'] = code + iq['resp']['message'] = message iq['resp']['version'] = '1.1' # TODO: set this implicitly - if data: + if data is not None: iq['resp']['data'] = data - print iq - # return iq.send(timeout=kwargs.get('timeout', None), - # block=kwargs.get('block', True), - # callback=kwargs.get('callback', None), - # timeout_callback=kwargs.get('timeout_callback', None)) - + return iq.send( + timeout=kwargs.get('timeout', None), + block=kwargs.get('block', True), + callback=kwargs.get('callback', None), + timeout_callback=kwargs.get('timeout_callback', None) + ) + + def send_error(self, to=None, ecode=500, etype='wait', + econd='internal-server-error', **kwargs): + iq = self.xmpp.Iq() + iq['type'] = 'error' + iq['from'] = self.xmpp.boundjid + iq['to'] = to + iq['error']['code'] = ecode + iq['error']['type'] = etype + iq['error']['condition'] = econd + return iq.send( + timeout=kwargs.get('timeout', None), + block=kwargs.get('block', True), + callback=kwargs.get('callback', None), + timeout_callback=kwargs.get('timeout_callback', None) + ) -- cgit v1.2.3 From 61a7cecb319c5628973906250ed973f21883cfd4 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Wed, 29 Apr 2015 14:44:25 +0530 Subject: Prefixed request, response and data with http. Avoided (plugin_attrib) name collision with other plugins. --- sleekxmpp/plugins/xep_0332/http.py | 56 ++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 36b6995f..acaef505 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -17,7 +17,9 @@ from sleekxmpp.xmlstream.handler import Callback from sleekxmpp.xmlstream.matcher import StanzaPath from sleekxmpp.plugins.base import BasePlugin -from sleekxmpp.plugins.xep_0332.stanza import Request, Response, Data +from sleekxmpp.plugins.xep_0332.stanza import ( + HTTPRequest, HTTPResponse, HTTPData +) from sleekxmpp.plugins.xep_0131.stanza import Headers @@ -50,18 +52,26 @@ class XEP_0332(BasePlugin): } def plugin_init(self): - self.xmpp.register_handler(Callback( - 'HTTP Request', StanzaPath('iq/req'), self._handle_request - )) - self.xmpp.register_handler(Callback( - 'HTTP Response', StanzaPath('iq/resp'), self._handle_response - )) - register_stanza_plugin(Iq, Request, iterable=True) - register_stanza_plugin(Iq, Response, iterable=True) - register_stanza_plugin(Request, Headers, iterable=True) - register_stanza_plugin(Request, Data, iterable=True) - register_stanza_plugin(Response, Headers, iterable=True) - register_stanza_plugin(Response, Data, iterable=True) + self.xmpp.register_handler( + Callback( + 'HTTP Request', + StanzaPath('iq/http-req'), + self._handle_request + ) + ) + self.xmpp.register_handler( + Callback( + 'HTTP Response', + StanzaPath('iq/http-resp'), + self._handle_response + ) + ) + register_stanza_plugin(Iq, HTTPRequest, iterable=True) + register_stanza_plugin(Iq, HTTPResponse, iterable=True) + register_stanza_plugin(HTTPRequest, Headers, iterable=True) + register_stanza_plugin(HTTPRequest, HTTPData, iterable=True) + register_stanza_plugin(HTTPResponse, Headers, iterable=True) + register_stanza_plugin(HTTPResponse, HTTPData, iterable=True) # TODO: Should we register any api's here? self.api.register() def plugin_end(self): @@ -94,12 +104,12 @@ class XEP_0332(BasePlugin): iq['from'] = self.xmpp.boundjid iq['to'] = to iq['type'] = 'set' - iq['req']['headers'] = headers - iq['req']['method'] = method - iq['req']['resource'] = resource - iq['req']['version'] = '1.1' # TODO: set this implicitly + iq['http-req']['headers'] = headers + iq['http-req']['method'] = method + iq['http-req']['resource'] = resource + iq['http-req']['version'] = '1.1' # TODO: set this implicitly if data is not None: - iq['req']['data'] = data + iq['http-req']['http-data'] = data return iq.send( timeout=kwargs.get('timeout', None), block=kwargs.get('block', True), @@ -113,12 +123,12 @@ class XEP_0332(BasePlugin): iq['from'] = self.xmpp.boundjid iq['to'] = to iq['type'] = 'result' - iq['resp']['headers'] = headers - iq['resp']['code'] = code - iq['resp']['message'] = message - iq['resp']['version'] = '1.1' # TODO: set this implicitly + iq['http-resp']['headers'] = headers + iq['http-resp']['code'] = code + iq['http-resp']['message'] = message + iq['http-resp']['version'] = '1.1' # TODO: set this implicitly if data is not None: - iq['resp']['data'] = data + iq['http-resp']['http-data'] = data return iq.send( timeout=kwargs.get('timeout', None), block=kwargs.get('block', True), -- cgit v1.2.3 From d60a652259c74aaea4a250c542ce5ceaeb81f177 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Fri, 1 May 2015 14:32:36 +0530 Subject: data need not be prefixed with http.. --- sleekxmpp/plugins/xep_0332/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index acaef505..5c1cfc0d 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -109,7 +109,7 @@ class XEP_0332(BasePlugin): iq['http-req']['resource'] = resource iq['http-req']['version'] = '1.1' # TODO: set this implicitly if data is not None: - iq['http-req']['http-data'] = data + iq['http-req']['data'] = data return iq.send( timeout=kwargs.get('timeout', None), block=kwargs.get('block', True), @@ -128,7 +128,7 @@ class XEP_0332(BasePlugin): iq['http-resp']['message'] = message iq['http-resp']['version'] = '1.1' # TODO: set this implicitly if data is not None: - iq['http-resp']['http-data'] = data + iq['http-resp']['data'] = data return iq.send( timeout=kwargs.get('timeout', None), block=kwargs.get('block', True), -- cgit v1.2.3 From 1345b7c1d0b3c121471034521e9028cd43569cb7 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Fri, 1 May 2015 15:34:53 +0530 Subject: Misc updates for send_error() --- sleekxmpp/plugins/xep_0332/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 5c1cfc0d..03d88b65 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -136,12 +136,12 @@ class XEP_0332(BasePlugin): timeout_callback=kwargs.get('timeout_callback', None) ) - def send_error(self, to=None, ecode=500, etype='wait', + def send_error(self, to=None, ecode='500', etype='wait', econd='internal-server-error', **kwargs): iq = self.xmpp.Iq() - iq['type'] = 'error' iq['from'] = self.xmpp.boundjid iq['to'] = to + iq['type'] = 'error' iq['error']['code'] = ecode iq['error']['type'] = etype iq['error']['condition'] = econd -- cgit v1.2.3 From eeab646bfa0d4787a2611f9c07514ddbb10ee441 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Sat, 1 Aug 2015 17:47:03 +0530 Subject: Retaining 'id' in the response and error stanzas --- sleekxmpp/plugins/xep_0332/http.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 03d88b65..92e2546f 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -127,6 +127,8 @@ class XEP_0332(BasePlugin): iq['http-resp']['code'] = code iq['http-resp']['message'] = message iq['http-resp']['version'] = '1.1' # TODO: set this implicitly + if 'id' in kwargs: + iq['id'] = kwargs["id"] if data is not None: iq['http-resp']['data'] = data return iq.send( @@ -145,6 +147,8 @@ class XEP_0332(BasePlugin): iq['error']['code'] = ecode iq['error']['type'] = etype iq['error']['condition'] = econd + if 'id' in kwargs: + iq['id'] = kwargs["id"] return iq.send( timeout=kwargs.get('timeout', None), block=kwargs.get('block', True), -- cgit v1.2.3 From 18e5abb9ddc1689e7e5963cf40259a2685eed9b5 Mon Sep 17 00:00:00 2001 From: Sangeeth Saravanaraj Date: Thu, 27 Aug 2015 13:24:01 +0530 Subject: adding 'id' to self['xep_0332'].send_request() --- sleekxmpp/plugins/xep_0332/http.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sleekxmpp/plugins/xep_0332/http.py') diff --git a/sleekxmpp/plugins/xep_0332/http.py b/sleekxmpp/plugins/xep_0332/http.py index 92e2546f..70bcafa6 100644 --- a/sleekxmpp/plugins/xep_0332/http.py +++ b/sleekxmpp/plugins/xep_0332/http.py @@ -108,6 +108,8 @@ class XEP_0332(BasePlugin): iq['http-req']['method'] = method iq['http-req']['resource'] = resource iq['http-req']['version'] = '1.1' # TODO: set this implicitly + if 'id' in kwargs: + iq['id'] = kwargs["id"] if data is not None: iq['http-req']['data'] = data return iq.send( -- cgit v1.2.3