Prefixed request, response and data with http. Avoided (plugin_attrib) name collision with other plugins.
This commit is contained in:
@@ -8,6 +8,6 @@
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
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
|
||||
from sleekxmpp.plugins.xep_0332.stanza.request import HTTPRequest
|
||||
from sleekxmpp.plugins.xep_0332.stanza.response import HTTPResponse
|
||||
from sleekxmpp.plugins.xep_0332.stanza.data import HTTPData
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
|
||||
|
||||
class Data(ElementBase):
|
||||
class HTTPData(ElementBase):
|
||||
"""
|
||||
The data element.
|
||||
"""
|
||||
name = 'data'
|
||||
namespace = 'urn:xmpp:http'
|
||||
interfaces = set(['data'])
|
||||
plugin_attrib = 'data'
|
||||
plugin_attrib = 'http-data'
|
||||
is_extension = True
|
||||
|
||||
def get_data(self, encoding='text'):
|
||||
|
||||
@@ -11,16 +11,19 @@
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
|
||||
|
||||
class Request(ElementBase):
|
||||
class HTTPRequest(ElementBase):
|
||||
|
||||
"""
|
||||
All HTTP communication is done using the `Request`/`Response` paradigm.
|
||||
Each HTTP Request is made sending an `iq` stanza containing a `req` element
|
||||
to the server. Each `iq` stanza sent is of type `set`.
|
||||
Each HTTP Request is made sending an `iq` stanza containing a `req`
|
||||
element to the server. Each `iq` stanza sent is of type `set`.
|
||||
|
||||
Examples:
|
||||
<iq type='set' from='a@b.com/browser' to='x@y.com' id='1'>
|
||||
<req xmlns='urn:xmpp:http' method='GET' resource='/api/users' 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>
|
||||
@@ -28,7 +31,10 @@ class Request(ElementBase):
|
||||
</iq>
|
||||
|
||||
<iq type='set' from='a@b.com/browser' to='x@y.com' id='2'>
|
||||
<req xmlns='urn:xmpp:http' method='PUT' resource='/api/users' version='1.1'>
|
||||
<req xmlns='urn:xmpp:http'
|
||||
method='PUT'
|
||||
resource='/api/users'
|
||||
version='1.1'>
|
||||
<headers xmlns='http://jabber.org/protocol/shim'>
|
||||
<header name='Host'>b.com</header>
|
||||
<header name='Content-Type'>text/html</header>
|
||||
@@ -44,7 +50,7 @@ class Request(ElementBase):
|
||||
name = 'request'
|
||||
namespace = 'urn:xmpp:http'
|
||||
interfaces = set(['method', 'resource', 'version'])
|
||||
plugin_attrib = 'req'
|
||||
plugin_attrib = 'http-req'
|
||||
|
||||
def get_method(self):
|
||||
return self._get_attr('method', None)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
from sleekxmpp.xmlstream import ElementBase
|
||||
|
||||
|
||||
class Response(ElementBase):
|
||||
class HTTPResponse(ElementBase):
|
||||
|
||||
"""
|
||||
When the HTTP Server responds, it does so by sending an `iq` stanza
|
||||
@@ -21,8 +21,13 @@ class Response(ElementBase):
|
||||
in which the original requests were made.
|
||||
|
||||
Examples:
|
||||
<iq type='result' from='httpserver@clayster.com' to='httpclient@clayster.com/browser' id='2'>
|
||||
<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>
|
||||
<iq type='result'
|
||||
from='httpserver@clayster.com'
|
||||
to='httpclient@clayster.com/browser' id='2'>
|
||||
<resp xmlns='urn:xmpp:http'
|
||||
version='1.1'
|
||||
statusCode='200'
|
||||
statusMessage='OK'>
|
||||
<headers xmlns='http://jabber.org/protocol/shim'>
|
||||
<header name='Date'>Fri, 03 May 2013 16:39:54GMT-4</header>
|
||||
<header name='Server'>Clayster</header>
|
||||
@@ -42,7 +47,7 @@ class Response(ElementBase):
|
||||
name = 'response'
|
||||
namespace = 'urn:xmpp:http'
|
||||
interfaces = set(['code', 'message', 'version'])
|
||||
plugin_attrib = 'resp'
|
||||
plugin_attrib = 'http-resp'
|
||||
|
||||
def get_code(self):
|
||||
code = self._get_attr('statusCode', None)
|
||||
|
||||
Reference in New Issue
Block a user