summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0332/stanza/request.py
diff options
context:
space:
mode:
authorRobert Robinson <rerobins@gmail.com>2015-09-18 13:30:30 -0600
committerRobert Robinson <rerobins@gmail.com>2015-09-18 13:30:30 -0600
commit5fc14de32e7fbd4e33a0e1ed92d8fb23871a2a2d (patch)
treed21287dbbb7882b766098e0a81c0d1d3677d28d3 /sleekxmpp/plugins/xep_0332/stanza/request.py
parente5582694c07236e6830c20361840360a1dde37f3 (diff)
parentd245558fd5eeee4fa34731ccea47c4c3132d805f (diff)
downloadslixmpp-5fc14de32e7fbd4e33a0e1ed92d8fb23871a2a2d.tar.gz
slixmpp-5fc14de32e7fbd4e33a0e1ed92d8fb23871a2a2d.tar.bz2
slixmpp-5fc14de32e7fbd4e33a0e1ed92d8fb23871a2a2d.tar.xz
slixmpp-5fc14de32e7fbd4e33a0e1ed92d8fb23871a2a2d.zip
Merge pull request #3 from fritzy/develop
Merge to fritzy_master
Diffstat (limited to 'sleekxmpp/plugins/xep_0332/stanza/request.py')
-rw-r--r--sleekxmpp/plugins/xep_0332/stanza/request.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0332/stanza/request.py b/sleekxmpp/plugins/xep_0332/stanza/request.py
new file mode 100644
index 00000000..9a298e57
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0332/stanza/request.py
@@ -0,0 +1,71 @@
+"""
+ 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 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`.
+
+ 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'>
+ <headers xmlns='http://jabber.org/protocol/shim'>
+ <header name='Host'>b.com</header>
+ </headers>
+ </req>
+ </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'>
+ <headers xmlns='http://jabber.org/protocol/shim'>
+ <header name='Host'>b.com</header>
+ <header name='Content-Type'>text/html</header>
+ <header name='Content-Length'>...</header>
+ </headers>
+ <data>
+ <text>...</text>
+ </data>
+ </req>
+ </iq>
+ """
+
+ name = 'request'
+ namespace = 'urn:xmpp:http'
+ interfaces = set(['method', 'resource', 'version'])
+ plugin_attrib = 'http-req'
+
+ def get_method(self):
+ return self._get_attr('method', None)
+
+ def set_method(self, method):
+ self._set_attr('method', method)
+
+ def get_resource(self):
+ return self._get_attr('resource', None)
+
+ def set_resource(self, resource):
+ self._set_attr('resource', resource)
+
+ def get_version(self):
+ return self._get_attr('version', None)
+
+ def set_version(self, version='1.1'):
+ self._set_attr('version', version)