diff --git a/tokio-xmpp/src/client/mod.rs b/tokio-xmpp/src/client/mod.rs index 531f003..af61311 100644 --- a/tokio-xmpp/src/client/mod.rs +++ b/tokio-xmpp/src/client/mod.rs @@ -177,6 +177,7 @@ impl Stream for Client { } Ok(Async::Ready(Some(Packet::Text(_)))) => { // Ignore text between stanzas + self.state = ClientState::Connected(stream); Ok(Async::NotReady) } Ok(Async::Ready(Some(Packet::StreamStart(_)))) => { diff --git a/tokio-xmpp/src/xmpp_codec.rs b/tokio-xmpp/src/xmpp_codec.rs index 658ca2a..b1f6c42 100644 --- a/tokio-xmpp/src/xmpp_codec.rs +++ b/tokio-xmpp/src/xmpp_codec.rs @@ -229,9 +229,8 @@ impl Decoder for XMPPCodec { }; let buf1 = buf1.as_ref().as_ref(); match from_utf8(buf1) { - Ok(mut s) => { + Ok(s) => { debug!("<< {:?}", s); - s = s.trim(); if !s.is_empty() { let mut buffer_queue = BufferQueue::new(); let tendril = FromIterator::from_iter(s.chars()); @@ -503,7 +502,7 @@ mod tests { } #[test] - fn test_lone_whitespace() { + fn test_cut_out_stanza() { let mut c = XMPPCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put(r""); @@ -514,10 +513,11 @@ mod tests { }); b.clear(); - b.put(r" "); + b.put(r"Foo"); let r = c.decode(&mut b); assert!(match r { - Ok(None) => true, + Ok(Some(Packet::Stanza(_))) => true, _ => false, }); }