tokio-xmpp: update for minidom changes
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
eca44f5602
commit
33ee71bcb4
3 changed files with 14 additions and 11 deletions
|
@ -16,7 +16,7 @@ pub const NS_XMPP_TLS: &str = "urn:ietf:params:xml:ns:xmpp-tls";
|
||||||
pub async fn starttls<S: AsyncRead + AsyncWrite + Unpin>(
|
pub async fn starttls<S: AsyncRead + AsyncWrite + Unpin>(
|
||||||
mut xmpp_stream: XMPPStream<S>,
|
mut xmpp_stream: XMPPStream<S>,
|
||||||
) -> Result<TlsStream<S>, Error> {
|
) -> Result<TlsStream<S>, Error> {
|
||||||
let nonza = Element::builder("starttls").ns(NS_XMPP_TLS).build();
|
let nonza = Element::builder("starttls", NS_XMPP_TLS).build();
|
||||||
let packet = Packet::Stanza(nonza);
|
let packet = Packet::Stanza(nonza);
|
||||||
xmpp_stream.send(packet).await?;
|
xmpp_stream.send(packet).await?;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub async fn start<S: AsyncRead + AsyncWrite + Unpin>(
|
||||||
stream,
|
stream,
|
||||||
ns,
|
ns,
|
||||||
stream_id.clone(),
|
stream_id.clone(),
|
||||||
Element::builder(stream_id).build(),
|
Element::builder(stream_id, NS_XMPP_STREAM).build(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Ok(stream)
|
Ok(stream)
|
||||||
|
|
|
@ -95,12 +95,10 @@ impl ParserSink {
|
||||||
self.ns_stack.push(nss);
|
self.ns_stack.push(nss);
|
||||||
|
|
||||||
let el = {
|
let el = {
|
||||||
let mut el_builder = Element::builder(tag.name.local.as_ref());
|
let el_ns = self
|
||||||
if let Some(el_ns) =
|
.lookup_ns(&tag.name.prefix.map(|prefix| prefix.as_ref().to_owned()))
|
||||||
self.lookup_ns(&tag.name.prefix.map(|prefix| prefix.as_ref().to_owned()))
|
.unwrap();
|
||||||
{
|
let mut el_builder = Element::builder(tag.name.local.as_ref(), el_ns);
|
||||||
el_builder = el_builder.ns(el_ns);
|
|
||||||
}
|
|
||||||
for attr in &tag.attrs {
|
for attr in &tag.attrs {
|
||||||
match attr.name.local.as_ref() {
|
match attr.name.local.as_ref() {
|
||||||
"xmlns" => (),
|
"xmlns" => (),
|
||||||
|
@ -490,13 +488,18 @@ mod tests {
|
||||||
for _ in 0..2usize.pow(15) {
|
for _ in 0..2usize.pow(15) {
|
||||||
text = text + "A";
|
text = text + "A";
|
||||||
}
|
}
|
||||||
let stanza = Element::builder("message")
|
let stanza = Element::builder("message", "jabber:client")
|
||||||
.append(Element::builder("body").append(text.as_ref()).build())
|
.append(
|
||||||
|
Element::builder("body", "jabber:client")
|
||||||
|
.append(text.as_ref())
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
.build();
|
.build();
|
||||||
block_on(framed.send(Packet::Stanza(stanza))).expect("send");
|
block_on(framed.send(Packet::Stanza(stanza))).expect("send");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
framed.get_ref().get_ref(),
|
framed.get_ref().get_ref(),
|
||||||
&("<message><body>".to_owned() + &text + "</body></message>").as_bytes()
|
&("<message xmlns=\"jabber:client\"><body>".to_owned() + &text + "</body></message>")
|
||||||
|
.as_bytes()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue