Composing request and response.
This commit is contained in:
@@ -8,4 +8,6 @@
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
NAMESPACE = 'urn:xmpp:http'
|
||||
from sleekxmpp.plugins.xep_0332.stanza.request import Request
|
||||
from sleekxmpp.plugins.xep_0332.stanza.response import Response
|
||||
from sleekxmpp.plugins.xep_0332.stanza.data import Data
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
|
||||
|
||||
class Data(ElementBase):
|
||||
"""
|
||||
The data element.
|
||||
"""
|
||||
name = 'data'
|
||||
namespace = ''
|
||||
interfaces = set(['data'])
|
||||
plugin_attrib = 'data'
|
||||
|
||||
def get_data(self):
|
||||
print "Data:: get_data()"
|
||||
|
||||
def set_data(self, data, encoding='text'):
|
||||
print "Data:: set_data()"
|
||||
self._set_sub_text(encoding, text=data)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"""
|
||||
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
from sleekxmpp.plugins.xep_0332.stanza import NAMESPACE
|
||||
|
||||
|
||||
class Request(ElementBase):
|
||||
@@ -43,7 +42,28 @@ class Request(ElementBase):
|
||||
"""
|
||||
|
||||
name = 'request'
|
||||
namespace = NAMESPACE
|
||||
interfaces = set(('method', 'resource', 'version'))
|
||||
namespace = 'urn:xmpp:http'
|
||||
interfaces = set(['method', 'resource', 'version'])
|
||||
plugin_attrib = 'req'
|
||||
|
||||
def get_method(self):
|
||||
print "Request:: get_method()"
|
||||
|
||||
def set_method(self, method):
|
||||
print "Request:: set_method()"
|
||||
self._set_attr('method', method)
|
||||
|
||||
def get_resource(self):
|
||||
print "Request:: get_resource()"
|
||||
|
||||
def set_resource(self, resource):
|
||||
print "Request:: set_resource()"
|
||||
self._set_attr('resource', resource)
|
||||
|
||||
def get_version(self):
|
||||
print "Request:: get_version()"
|
||||
|
||||
def set_version(self, version='1.1'):
|
||||
print "Request:: set_version()"
|
||||
self._set_attr('version', version)
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"""
|
||||
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
from sleekxmpp.plugins.xep_0332.stanza import NAMESPACE
|
||||
|
||||
|
||||
class Response(ElementBase):
|
||||
@@ -41,6 +40,18 @@ class Response(ElementBase):
|
||||
"""
|
||||
|
||||
name = 'response'
|
||||
namespace = NAMESPACE
|
||||
interfaces = set(('statusCode', 'statusMessage', 'version'))
|
||||
namespace = 'urn:xmpp:http'
|
||||
interfaces = set(['code', 'version'])
|
||||
plugin_attrib = 'resp'
|
||||
|
||||
def get_code(self):
|
||||
print "Response:: get_code()"
|
||||
|
||||
def set_code(self, code):
|
||||
print "Response:: set_code()"
|
||||
self._set_attr('statusCode', str(code))
|
||||
self._set_attr('statusMessage', str(code))
|
||||
|
||||
def set_version(self, version='1.1'):
|
||||
print "Response:: set_version()"
|
||||
self._set_attr('version', version)
|
||||
|
||||
Reference in New Issue
Block a user