Permalink
Browse files

Merge branch 'master' of git://github.com/fritzy/SleekXMPP into develop

# By Lance Stout
# Via Lance Stout
* 'master' of git://github.com/fritzy/SleekXMPP:
  Turns out not all data is UTF-8, so don't try to decode it.
  • Loading branch information...
2 parents c8c20ff + 12e8bb6 commit 48def71d0c35755d0d34f3be4ebc35a26c12693b @hildjj hildjj committed Oct 31, 2012
Showing with 16 additions and 16 deletions.
  1. +1 −1 examples/ibb_transfer/ibb_receiver.py
  2. +1 −1 sleekxmpp/plugins/xep_0047/stanza.py
  3. +14 −14 tests/test_stream_xep_0047.py
@@ -85,7 +85,7 @@ def accept_stream(self, iq):
def stream_opened(self, stream):
# NOTE: IBB streams are bi-directional, so the original sender is
# now the opened stream's receiver.
- print('Stream opened: %s from ' % (stream.sid, stream.receiver))
+ print('Stream opened: %s from %s' % (stream.sid, stream.receiver))
# You could run a loop reading from the stream using stream.recv(),
# or use the ibb_stream_data event.
@@ -14,7 +14,7 @@ def to_b64(data):
def from_b64(data):
- return bytes(base64.b64decode(bytes(data))).decode('utf-8')
+ return bytes(base64.b64decode(bytes(data)))
class Open(ElementBase):
@@ -5,15 +5,15 @@
class TestInBandByteStreams(SleekTest):
-
+
def setUp(self):
self.stream_start(plugins=['xep_0047', 'xep_0030'])
def tearDown(self):
self.stream_close()
def testOpenStream(self):
- """Test requesting a stream, successfully"""
+ """Test requesting a stream, successfully"""
events = []
@@ -22,7 +22,7 @@ def on_stream_start(stream):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
-
+
t = threading.Thread(name='open_stream',
target=self.xmpp['xep_0047'].open_stream,
args=('tester@localhost/receiver',),
@@ -31,7 +31,7 @@ def on_stream_start(stream):
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
- <open xmlns="http://jabber.org/protocol/ibb"
+ <open xmlns="http://jabber.org/protocol/ibb"
sid="testing"
block-size="4096"
stanza="iq" />
@@ -62,18 +62,18 @@ def stream_callback(iq):
events.add('callback')
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
-
+
t = threading.Thread(name='open_stream',
target=self.xmpp['xep_0047'].open_stream,
args=('tester@localhost/receiver',),
- kwargs={'sid': 'testing',
+ kwargs={'sid': 'testing',
'block': False,
'callback': stream_callback})
t.start()
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
- <open xmlns="http://jabber.org/protocol/ibb"
+ <open xmlns="http://jabber.org/protocol/ibb"
sid="testing"
block-size="4096"
stanza="iq" />
@@ -106,7 +106,7 @@ def on_stream_data(d):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
self.xmpp.add_event_handler('ibb_stream_data', on_stream_data)
-
+
t = threading.Thread(name='open_stream',
target=self.xmpp['xep_0047'].open_stream,
args=('tester@localhost/receiver',),
@@ -115,7 +115,7 @@ def on_stream_data(d):
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
- <open xmlns="http://jabber.org/protocol/ibb"
+ <open xmlns="http://jabber.org/protocol/ibb"
sid="testing"
block-size="4096"
stanza="iq" />
@@ -142,8 +142,8 @@ def on_stream_data(d):
<iq type="set" id="2"
from="tester@localhost"
to="tester@localhost/receiver">
- <data xmlns="http://jabber.org/protocol/ibb"
- seq="0"
+ <data xmlns="http://jabber.org/protocol/ibb"
+ seq="0"
sid="testing">
VGVzdGluZw==
</data>
@@ -161,8 +161,8 @@ def on_stream_data(d):
<iq type="set" id="A"
to="tester@localhost"
from="tester@localhost/receiver">
- <data xmlns="http://jabber.org/protocol/ibb"
- seq="0"
+ <data xmlns="http://jabber.org/protocol/ibb"
+ seq="0"
sid="testing">
aXQgd29ya3Mh
</data>
@@ -174,7 +174,7 @@ def on_stream_data(d):
to="tester@localhost/receiver" />
""")
- self.assertEqual(data, ['it works!'])
+ self.assertEqual(data, [b'it works!'])
suite = unittest.TestLoader().loadTestsFromTestCase(TestInBandByteStreams)

0 comments on commit 48def71

Please sign in to comment.