diff options
Diffstat (limited to 'sleekxmpp/plugins/xep_0332/stanza')
-rw-r--r-- | sleekxmpp/plugins/xep_0332/stanza/data.py | 9 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0332/stanza/request.py | 14 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0332/stanza/response.py | 14 |
3 files changed, 19 insertions, 18 deletions
diff --git a/sleekxmpp/plugins/xep_0332/stanza/data.py b/sleekxmpp/plugins/xep_0332/stanza/data.py index e77d2585..9a08426b 100644 --- a/sleekxmpp/plugins/xep_0332/stanza/data.py +++ b/sleekxmpp/plugins/xep_0332/stanza/data.py @@ -16,14 +16,15 @@ class Data(ElementBase): The data element. """ name = 'data' - namespace = '' + namespace = 'urn:xmpp:http' interfaces = set(['data']) plugin_attrib = 'data' + is_extension = True - def get_data(self): - print "Data:: get_data()" + def get_data(self, encoding='text'): + data = self._get_sub_text(encoding, None) + return str(data) if data is not None else data def set_data(self, data, encoding='text'): - print "Data:: set_data()" self._set_sub_text(encoding, text=data) diff --git a/sleekxmpp/plugins/xep_0332/stanza/request.py b/sleekxmpp/plugins/xep_0332/stanza/request.py index 51e565e5..07618727 100644 --- a/sleekxmpp/plugins/xep_0332/stanza/request.py +++ b/sleekxmpp/plugins/xep_0332/stanza/request.py @@ -20,7 +20,7 @@ class Request(ElementBase): Examples: <iq type='set' from='a@b.com/browser' to='x@y.com' id='1'> - <req xmlns='urn:xmpp:http' method='GET' resource='/api/user' version='1.1'> + <req xmlns='urn:xmpp:http' method='GET' resource='/api/users' version='1.1'> <headers xmlns='http://jabber.org/protocol/shim'> <header name='Host'>b.com</header> </headers> @@ -35,7 +35,7 @@ class Request(ElementBase): <header name='Content-Length'>...</header> </headers> <data> - <text><html><header/><body><p>Beautiful home page.</p></body></html></text> + <text>...</text> </data> </req> </iq> @@ -47,23 +47,19 @@ class Request(ElementBase): plugin_attrib = 'req' def get_method(self): - print "Request:: get_method()" + return self._get_attr('method', None) def set_method(self, method): - print "Request:: set_method()" self._set_attr('method', method) def get_resource(self): - print "Request:: get_resource()" + return self._get_attr('resource', None) def set_resource(self, resource): - print "Request:: set_resource()" self._set_attr('resource', resource) def get_version(self): - print "Request:: get_version()" + return self._get_attr('version', None) def set_version(self, version='1.1'): - print "Request:: set_version()" self._set_attr('version', version) - diff --git a/sleekxmpp/plugins/xep_0332/stanza/response.py b/sleekxmpp/plugins/xep_0332/stanza/response.py index d863efa3..0fc46de8 100644 --- a/sleekxmpp/plugins/xep_0332/stanza/response.py +++ b/sleekxmpp/plugins/xep_0332/stanza/response.py @@ -41,17 +41,21 @@ class Response(ElementBase): name = 'response' namespace = 'urn:xmpp:http' - interfaces = set(['code', 'version']) + interfaces = set(['code', 'message', 'version']) plugin_attrib = 'resp' def get_code(self): - print "Response:: get_code()" + code = self._get_attr('statusCode', None) + return int(code) if code is not None else code def set_code(self, code): - print "Response:: set_code()" self._set_attr('statusCode', str(code)) - self._set_attr('statusMessage', str(code)) + + def get_message(self): + return self._get_attr('statusMessage', '') + + def set_message(self, message): + self._set_attr('statusMessage', message) def set_version(self, version='1.1'): - print "Response:: set_version()" self._set_attr('version', version) |