aboutsummaryrefslogtreecommitdiff
path: root/src/dav/decoder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dav/decoder.rs')
-rw-r--r--src/dav/decoder.rs433
1 files changed, 225 insertions, 208 deletions
diff --git a/src/dav/decoder.rs b/src/dav/decoder.rs
index 4acd3e8..fd11cf0 100644
--- a/src/dav/decoder.rs
+++ b/src/dav/decoder.rs
@@ -25,36 +25,32 @@ use super::xml::{Node, QRead, Reader, IRead, DAV_URN, CAL_URN};
/// Propfind request
impl<E: Extension> QRead<PropFind<E>> for PropFind<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
- // Find propfind
xml.open(DAV_URN, "propfind").await?;
-
- // Find any tag
let propfind: PropFind<E> = loop {
- match xml.peek() {
- Event::Start(_) if xml.is_tag(DAV_URN, "allprop") => {
- xml.open(DAV_URN, "allprop").await?;
- let includ = xml.maybe_find::<Include<E>>().await?;
- let r = PropFind::AllProp(includ);
- xml.tag_stop(DAV_URN, "allprop").await?;
- break r
- },
- Event::Start(_) if xml.is_tag(DAV_URN, "prop") => {
- break PropFind::Prop(xml.find::<PropName<E>>().await?);
- },
- Event::Empty(_) if xml.is_tag(DAV_URN, "allprop") => {
- xml.next().await?;
- break PropFind::AllProp(None)
- },
- Event::Empty(_) if xml.is_tag(DAV_URN, "propname") => {
- xml.next().await?;
- break PropFind::PropName
- },
- _ => { xml.skip().await?; },
+ // allprop
+ if let Some(_) = xml.maybe_open(DAV_URN, "allprop").await? {
+ let includ = xml.maybe_find::<Include<E>>().await?;
+ xml.close().await?;
+ break PropFind::AllProp(includ)
}
- };
- // Close tag
- xml.tag_stop(DAV_URN, "propfind").await?;
+ // propname
+ if let Some(_) = xml.maybe_open(DAV_URN, "propname").await? {
+ xml.close().await?;
+ break PropFind::PropName
+ }
+
+ // prop
+ let (mut maybe_prop, mut dirty) = (None, false);
+ xml.maybe_read::<PropName<E>>(&mut maybe_prop, &mut dirty).await?;
+ if let Some(prop) = maybe_prop {
+ break PropFind::Prop(prop)
+ }
+
+ // not found, skipping
+ xml.skip().await?;
+ };
+ xml.close().await?;
Ok(propfind)
}
@@ -65,7 +61,7 @@ impl<E: Extension> QRead<PropertyUpdate<E>> for PropertyUpdate<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "propertyupdate").await?;
let collected_items = xml.collect::<PropertyUpdateItem<E>>().await?;
- xml.tag_stop(DAV_URN, "propertyupdate").await?;
+ xml.close().await?;
Ok(PropertyUpdate(collected_items))
}
}
@@ -89,7 +85,7 @@ impl<E: Extension, N: Node<N>> QRead<Multistatus<E,N>> for Multistatus<E,N> {
}
}
- xml.tag_stop(DAV_URN, "multistatus").await?;
+ xml.close().await?;
Ok(Multistatus { responses, responsedescription })
}
}
@@ -112,7 +108,7 @@ impl QRead<LockInfo> for LockInfo {
};
}
}
- xml.tag_stop(DAV_URN, "lockinfo").await?;
+ xml.close().await?;
match (m_scope, m_type) {
(Some(lockscope), Some(locktype)) => Ok(LockInfo { lockscope, locktype, owner }),
_ => Err(ParsingError::MissingChild),
@@ -125,7 +121,7 @@ impl<E: Extension> QRead<PropValue<E>> for PropValue<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "prop").await?;
let mut acc = xml.collect::<Property<E>>().await?;
- xml.tag_stop(DAV_URN, "prop").await?;
+ xml.close().await?;
Ok(PropValue(acc))
}
}
@@ -136,7 +132,7 @@ impl<E: Extension> QRead<Error<E>> for Error<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "error").await?;
let violations = xml.collect::<Violation<E>>().await?;
- xml.tag_stop(DAV_URN, "error").await?;
+ xml.close().await?;
Ok(Error(violations))
}
}
@@ -168,7 +164,7 @@ impl<E: Extension, N: Node<N>> QRead<Response<E,N>> for Response<E,N> {
}
}
- xml.tag_stop(DAV_URN, "response").await?;
+ xml.close().await?;
match (status, &propstat[..], &href[..]) {
(Some(status), &[], &[_, ..]) => Ok(Response {
status_or_propstat: StatusOrPropstat::Status(href, status),
@@ -205,7 +201,7 @@ impl<E: Extension, N: Node<N>> QRead<PropStat<E,N>> for PropStat<E,N> {
}
}
- xml.tag_stop(DAV_URN, "propstat").await?;
+ xml.close().await?;
match (m_prop, m_status) {
(Some(prop), Some(status)) => Ok(PropStat { prop, status, error, responsedescription }),
_ => Err(ParsingError::MissingChild),
@@ -219,7 +215,7 @@ impl QRead<Status> for Status {
let fullcode = xml.tag_string().await?;
let txtcode = fullcode.splitn(3, ' ').nth(1).ok_or(ParsingError::InvalidValue)?;
let code = http::status::StatusCode::from_bytes(txtcode.as_bytes()).or(Err(ParsingError::InvalidValue))?;
- xml.tag_stop(DAV_URN, "status").await?;
+ xml.close().await?;
Ok(Status(code))
}
}
@@ -228,7 +224,7 @@ impl QRead<ResponseDescription> for ResponseDescription {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "responsedescription").await?;
let cnt = xml.tag_string().await?;
- xml.tag_stop(DAV_URN, "responsedescription").await?;
+ xml.close().await?;
Ok(ResponseDescription(cnt))
}
}
@@ -237,7 +233,7 @@ impl QRead<Location> for Location {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "location").await?;
let href = xml.find::<Href>().await?;
- xml.tag_stop(DAV_URN, "location").await?;
+ xml.close().await?;
Ok(Location(href))
}
}
@@ -256,7 +252,7 @@ impl<E: Extension> QRead<Remove<E>> for Remove<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "remove").await?;
let propname = xml.find::<PropName<E>>().await?;
- xml.tag_stop(DAV_URN, "remove").await?;
+ xml.close().await?;
Ok(Remove(propname))
}
}
@@ -265,61 +261,39 @@ impl<E: Extension> QRead<Set<E>> for Set<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "set").await?;
let propvalue = xml.find::<PropValue<E>>().await?;
- xml.tag_stop(DAV_URN, "set").await?;
+ xml.close().await?;
Ok(Set(propvalue))
}
}
impl<E: Extension> QRead<Violation<E>> for Violation<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
- let bs = match xml.peek() {
- Event::Start(b) | Event::Empty(b) => b,
- _ => return Err(ParsingError::Recoverable),
- };
-
- // Option 1: a pure DAV property
- let (ns, loc) = xml.rdr.resolve_element(bs.name());
- if matches!(ns, Bound(Namespace(ns)) if ns == DAV_URN) {
- match loc.into_inner() {
- b"lock-token-matches-request-uri" => {
- xml.next().await?;
- return Ok(Violation::LockTokenMatchesRequestUri)
- },
- b"lock-token-submitted" => {
- xml.next().await?;
- let links = xml.collect::<Href>().await?;
- xml.tag_stop(DAV_URN, "lock-token-submitted").await?;
- return Ok(Violation::LockTokenSubmitted(links))
- },
- b"no-conflicting-lock" => {
- // start tag
- xml.next().await?;
- let links = xml.collect::<Href>().await?;
- xml.tag_stop(DAV_URN, "no-conflicting-lock").await?;
- return Ok(Violation::NoConflictingLock(links))
- },
- b"no-external-entities" => {
- xml.next().await?;
- return Ok(Violation::NoExternalEntities)
- },
- b"preserved-live-properties" => {
- xml.next().await?;
- return Ok(Violation::PreservedLiveProperties)
- },
- b"propfind-finite-depth" => {
- xml.next().await?;
- return Ok(Violation::PropfindFiniteDepth)
- },
- b"cannot-modify-protected-property" => {
- xml.next().await?;
- return Ok(Violation::CannotModifyProtectedProperty)
- },
- _ => (),
- };
+ if xml.maybe_open(DAV_URN, "lock-token-matches-request-uri").await?.is_some() {
+ xml.close().await?;
+ Ok(Violation::LockTokenMatchesRequestUri)
+ } else if xml.maybe_open(DAV_URN, "lock-token-submitted").await?.is_some() {
+ let links = xml.collect::<Href>().await?;
+ xml.close().await?;
+ Ok(Violation::LockTokenSubmitted(links))
+ } else if xml.maybe_open(DAV_URN, "no-conflicting-lock").await?.is_some() {
+ let links = xml.collect::<Href>().await?;
+ xml.close().await?;
+ Ok(Violation::NoConflictingLock(links))
+ } else if xml.maybe_open(DAV_URN, "no-external-entities").await?.is_some() {
+ xml.close().await?;
+ Ok(Violation::NoExternalEntities)
+ } else if xml.maybe_open(DAV_URN, "preserved-live-properties").await?.is_some() {
+ xml.close().await?;
+ Ok(Violation::PreservedLiveProperties)
+ } else if xml.maybe_open(DAV_URN, "propfind-finite-depth").await?.is_some() {
+ xml.close().await?;
+ Ok(Violation::PropfindFiniteDepth)
+ } else if xml.maybe_open(DAV_URN, "cannot-modify-protected-property").await?.is_some() {
+ xml.close().await?;
+ Ok(Violation::CannotModifyProtectedProperty)
+ } else {
+ E::Error::qread(xml).await.map(Violation::Extension)
}
-
- // Option 2: an extension property, delegating
- E::Error::qread(xml).await.map(Violation::Extension)
}
}
@@ -327,7 +301,7 @@ impl<E: Extension> QRead<Include<E>> for Include<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "include").await?;
let acc = xml.collect::<PropertyRequest<E>>().await?;
- xml.tag_stop(DAV_URN, "include").await?;
+ xml.close().await?;
Ok(Include(acc))
}
}
@@ -336,43 +310,44 @@ impl<E: Extension> QRead<PropName<E>> for PropName<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "prop").await?;
let acc = xml.collect::<PropertyRequest<E>>().await?;
- xml.tag_stop(DAV_URN, "prop").await?;
+ xml.close().await?;
Ok(PropName(acc))
}
}
impl<E: Extension> QRead<PropertyRequest<E>> for PropertyRequest<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
- let bs = match xml.peek() {
- Event::Start(b) | Event::Empty(b) => b,
- _ => return Err(ParsingError::Recoverable),
+ let maybe = if xml.maybe_open(DAV_URN, "creationdate").await?.is_some() {
+ Some(PropertyRequest::CreationDate)
+ } else if xml.maybe_open(DAV_URN, "displayname").await?.is_some() {
+ Some(PropertyRequest::DisplayName)
+ } else if xml.maybe_open(DAV_URN, "getcontentlanguage").await?.is_some() {
+ Some(PropertyRequest::GetContentLanguage)
+ } else if xml.maybe_open(DAV_URN, "getcontentlength").await?.is_some() {
+ Some(PropertyRequest::GetContentLength)
+ } else if xml.maybe_open(DAV_URN, "getcontenttype").await?.is_some() {
+ Some(PropertyRequest::GetContentType)
+ } else if xml.maybe_open(DAV_URN, "getetag").await?.is_some() {
+ Some(PropertyRequest::GetEtag)
+ } else if xml.maybe_open(DAV_URN, "getlastmodified").await?.is_some() {
+ Some(PropertyRequest::GetLastModified)
+ } else if xml.maybe_open(DAV_URN, "lockdiscovery").await?.is_some() {
+ Some(PropertyRequest::LockDiscovery)
+ } else if xml.maybe_open(DAV_URN, "resourcetype").await?.is_some() {
+ Some(PropertyRequest::ResourceType)
+ } else if xml.maybe_open(DAV_URN, "supportedlock").await?.is_some() {
+ Some(PropertyRequest::SupportedLock)
+ } else {
+ None
};
- // Option 1: a pure core DAV property
- let (ns, loc) = xml.rdr.resolve_element(bs.name());
- if matches!(ns, Bound(Namespace(ns)) if ns == DAV_URN) {
- let maybe_res = match loc.into_inner() {
- b"creationdate" => Some(PropertyRequest::CreationDate),
- b"displayname" => Some(PropertyRequest::DisplayName),
- b"getcontentlanguage" => Some(PropertyRequest::GetContentLanguage),
- b"getcontentlength" => Some(PropertyRequest::GetContentLength),
- b"getcontenttype" => Some(PropertyRequest::GetContentType),
- b"getetag" => Some(PropertyRequest::GetEtag),
- b"getlastmodified" => Some(PropertyRequest::GetLastModified),
- b"lockdiscovery" => Some(PropertyRequest::LockDiscovery),
- b"resourcetype" => Some(PropertyRequest::ResourceType),
- b"supportedlock" => Some(PropertyRequest::SupportedLock),
- _ => None,
- };
- // Close the current tag if we read something
- if let Some(res) = maybe_res {
- xml.skip().await?;
- return Ok(res)
- }
+ match maybe {
+ Some(pr) => {
+ xml.close().await?;
+ Ok(pr)
+ },
+ None => E::PropertyRequest::qread(xml).await.map(PropertyRequest::Extension),
}
-
- // Option 2: an extension property, delegating
- E::PropertyRequest::qread(xml).await.map(PropertyRequest::Extension)
}
}
@@ -380,66 +355,47 @@ impl<E: Extension> QRead<Property<E>> for Property<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
use chrono::{DateTime, FixedOffset, TimeZone};
- let bs = match xml.peek() {
- Event::Start(b) | Event::Empty(b) => b,
- _ => return Err(ParsingError::Recoverable),
- };
-
- // Option 1: a pure core DAV property
- let (ns, loc) = xml.rdr.resolve_element(bs.name());
- if matches!(ns, Bound(Namespace(ns)) if ns == DAV_URN) {
- match loc.into_inner() {
- b"creationdate" => {
- xml.next().await?;
- let datestr = xml.tag_string().await?;
- return Ok(Property::CreationDate(DateTime::parse_from_rfc3339(datestr.as_str())?))
- },
- b"displayname" => {
- xml.next().await?;
- return Ok(Property::DisplayName(xml.tag_string().await?))
- },
- b"getcontentlanguage" => {
- xml.next().await?;
- return Ok(Property::GetContentLanguage(xml.tag_string().await?))
- },
- b"getcontentlength" => {
- xml.next().await?;
- let cl = xml.tag_string().await?.parse::<u64>()?;
- return Ok(Property::GetContentLength(cl))
- },
- b"getcontenttype" => {
- xml.next().await?;
- return Ok(Property::GetContentType(xml.tag_string().await?))
- },
- b"getetag" => {
- xml.next().await?;
- return Ok(Property::GetEtag(xml.tag_string().await?))
- },
- b"getlastmodified" => {
- xml.next().await?;
- let datestr = xml.tag_string().await?;
- return Ok(Property::CreationDate(DateTime::parse_from_rfc2822(datestr.as_str())?))
- },
- b"lockdiscovery" => {
- xml.next().await?;
- let acc = xml.collect::<ActiveLock>().await?;
- xml.tag_stop(DAV_URN, "lockdiscovery").await?;
- return Ok(Property::LockDiscovery(acc))
- },
- b"resourcetype" => {
- xml.next().await?;
- let acc = xml.collect::<ResourceType<E>>().await?;
- xml.tag_stop(DAV_URN, "resourcetype").await?;
- return Ok(Property::ResourceType(acc))
- },
- b"supportedlock" => {
- xml.next().await?;
- let acc = xml.collect::<LockEntry>().await?;
- xml.tag_stop(DAV_URN, "supportedlock").await?;
- return Ok(Property::SupportedLock(acc))
- },
- _ => (),
- };
+ // Core WebDAV properties
+ if xml.maybe_open(DAV_URN, "creationdate").await?.is_some() {
+ let datestr = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::CreationDate(DateTime::parse_from_rfc3339(datestr.as_str())?))
+ } else if xml.maybe_open(DAV_URN, "displayname").await?.is_some() {
+ let name = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::DisplayName(name))
+ } else if xml.maybe_open(DAV_URN, "getcontentlanguage").await?.is_some() {
+ let lang = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::GetContentLanguage(lang))
+ } else if xml.maybe_open(DAV_URN, "getcontentlength").await?.is_some() {
+ let cl = xml.tag_string().await?.parse::<u64>()?;
+ xml.close().await?;
+ return Ok(Property::GetContentLength(cl))
+ } else if xml.maybe_open(DAV_URN, "getcontenttype").await?.is_some() {
+ let ct = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::GetContentType(ct))
+ } else if xml.maybe_open(DAV_URN, "getetag").await?.is_some() {
+ let etag = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::GetEtag(etag))
+ } else if xml.maybe_open(DAV_URN, "getlastmodified").await?.is_some() {
+ let datestr = xml.tag_string().await?;
+ xml.close().await?;
+ return Ok(Property::CreationDate(DateTime::parse_from_rfc2822(datestr.as_str())?))
+ } else if xml.maybe_open(DAV_URN, "lockdiscovery").await?.is_some() {
+ let acc = xml.collect::<ActiveLock>().await?;
+ xml.close().await?;
+ return Ok(Property::LockDiscovery(acc))
+ } else if xml.maybe_open(DAV_URN, "resourcetype").await?.is_some() {
+ let acc = xml.collect::<ResourceType<E>>().await?;
+ xml.close().await?;
+ return Ok(Property::ResourceType(acc))
+ } else if xml.maybe_open(DAV_URN, "supportedlock").await?.is_some() {
+ let acc = xml.collect::<LockEntry>().await?;
+ xml.close().await?;
+ return Ok(Property::SupportedLock(acc))
}
// Option 2: an extension property, delegating
@@ -471,7 +427,7 @@ impl QRead<ActiveLock> for ActiveLock {
}
}
- xml.tag_stop(DAV_URN, "activelock").await?;
+ xml.close().await?;
match (m_scope, m_type, m_depth, m_root) {
(Some(lockscope), Some(locktype), Some(depth), Some(lockroot)) =>
Ok(ActiveLock { lockscope, locktype, depth, owner, timeout, locktoken, lockroot }),
@@ -484,7 +440,7 @@ impl QRead<Depth> for Depth {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "depth").await?;
let depth_str = xml.tag_string().await?;
- xml.tag_stop(DAV_URN, "depth").await?;
+ xml.close().await?;
match depth_str.as_str() {
"0" => Ok(Depth::Zero),
"1" => Ok(Depth::One),
@@ -518,7 +474,7 @@ impl QRead<Owner> for Owner {
_ => { xml.skip().await?; },
}
};
- xml.tag_stop(DAV_URN, "owner").await?;
+ xml.close().await?;
Ok(owner)
}
}
@@ -536,7 +492,7 @@ impl QRead<Timeout> for Timeout {
},
};
- xml.tag_stop(DAV_URN, "timeout").await?;
+ xml.close().await?;
Ok(timeout)
}
}
@@ -545,7 +501,7 @@ impl QRead<LockToken> for LockToken {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "locktoken").await?;
let href = Href::qread(xml).await?;
- xml.tag_stop(DAV_URN, "locktoken").await?;
+ xml.close().await?;
Ok(LockToken(href))
}
}
@@ -554,20 +510,19 @@ impl QRead<LockRoot> for LockRoot {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "lockroot").await?;
let href = Href::qread(xml).await?;
- xml.tag_stop(DAV_URN, "lockroot").await?;
+ xml.close().await?;
Ok(LockRoot(href))
}
}
impl<E: Extension> QRead<ResourceType<E>> for ResourceType<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
- match xml.peek() {
- Event::Empty(b) if xml.is_tag(DAV_URN, "collection") => {
- xml.next().await?;
- Ok(ResourceType::Collection)
- },
- _ => E::ResourceType::qread(xml).await.map(ResourceType::Extension),
+ if xml.maybe_open(DAV_URN, "collection").await?.is_some() {
+ xml.close().await?;
+ return Ok(ResourceType::Collection)
}
+
+ E::ResourceType::qread(xml).await.map(ResourceType::Extension)
}
}
@@ -588,7 +543,7 @@ impl QRead<LockEntry> for LockEntry {
}
}
- xml.tag_stop(DAV_URN, "lockentry").await?;
+ xml.close().await?;
match (maybe_scope, maybe_type) {
(Some(lockscope), Some(locktype)) => Ok(LockEntry { lockscope, locktype }),
_ => Err(ParsingError::MissingChild),
@@ -601,20 +556,18 @@ impl QRead<LockScope> for LockScope {
xml.open(DAV_URN, "lockscope").await?;
let lockscope = loop {
- match xml.peek() {
- Event::Empty(_) if xml.is_tag(DAV_URN, "exclusive") => {
- xml.next().await?;
- break LockScope::Exclusive
- },
- Event::Empty(_) if xml.is_tag(DAV_URN, "shared") => {
- xml.next().await?;
- break LockScope::Shared
- }
- _ => xml.skip().await?,
- };
+ if xml.maybe_open(DAV_URN, "exclusive").await?.is_some() {
+ xml.close().await?;
+ break LockScope::Exclusive
+ } else if xml.maybe_open(DAV_URN, "shared").await?.is_some() {
+ xml.close().await?;
+ break LockScope::Shared
+ }
+
+ xml.skip().await?;
};
- xml.tag_stop(DAV_URN, "lockscope").await?;
+ xml.close().await?;
Ok(lockscope)
}
}
@@ -624,15 +577,15 @@ impl QRead<LockType> for LockType {
xml.open(DAV_URN, "locktype").await?;
let locktype = loop {
- match xml.peek() {
- Event::Empty(b) if xml.is_tag(DAV_URN, "write") => {
- xml.next().await?;
- break LockType::Write
- }
- _ => xml.skip().await?,
- };
+ if xml.maybe_open(DAV_URN, "write").await?.is_some() {
+ xml.close().await?;
+ break LockType::Write
+ }
+
+ xml.skip().await?;
};
- xml.tag_stop(DAV_URN, "locktype").await?;
+
+ xml.close().await?;
Ok(locktype)
}
}
@@ -641,7 +594,7 @@ impl QRead<Href> for Href {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "href").await?;
let mut url = xml.tag_string().await?;
- xml.tag_stop(DAV_URN, "href").await?;
+ xml.close().await?;
Ok(Href(url))
}
}
@@ -859,4 +812,68 @@ mod tests {
responsedescription: None,
});
}
+
+
+ #[tokio::test]
+ async fn rfc_multistatus_value() {
+ let src = r#"
+ <?xml version="1.0" encoding="utf-8" ?>
+ <D:multistatus xmlns:D="DAV:">
+ <D:response>
+ <D:href>/container/</D:href>
+ <D:propstat>
+ <D:prop xmlns:R="http://ns.example.com/boxschema/">
+ <R:bigbox><R:BoxType>Box type A</R:BoxType></R:bigbox>
+ <R:author><R:Name>Hadrian</R:Name></R:author>
+ <D:creationdate>1997-12-01T17:42:21-08:00</D:creationdate>
+ <D:displayname>Example collection</D:displayname>
+ <D:resourcetype><D:collection/></D:resourcetype>
+ <D:supportedlock>
+ <D:lockentry>
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ </D:lockentry>
+ <D:lockentry>
+ <D:lockscope><D:shared/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ </D:lockentry>
+ </D:supportedlock>
+ </D:prop>
+ <D:status>HTTP/1.1 200 OK</D:status>
+ </D:propstat>
+ </D:response>
+ <D:response>
+ <D:href>/container/front.html</D:href>
+ <D:propstat>
+ <D:prop xmlns:R="http://ns.example.com/boxschema/">
+ <R:bigbox><R:BoxType>Box type B</R:BoxType>
+ </R:bigbox>
+ <D:creationdate>1997-12-01T18:27:21-08:00</D:creationdate>
+ <D:displayname>Example HTML resource</D:displayname>
+ <D:getcontentlength>4525</D:getcontentlength>
+ <D:getcontenttype>text/html</D:getcontenttype>
+ <D:getetag>"zzyzx"</D:getetag>
+ <D:getlastmodified
+ >Mon, 12 Jan 1998 09:25:56 GMT</D:getlastmodified>
+ <D:resourcetype/>
+ <D:supportedlock>
+ <D:lockentry>
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ </D:lockentry>
+ <D:lockentry>
+ <D:lockscope><D:shared/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ </D:lockentry>
+ </D:supportedlock>
+ </D:prop>
+ <D:status>HTTP/1.1 200 OK</D:status>
+ </D:propstat>
+ </D:response>
+ </D:multistatus>"#;
+
+ let mut rdr = Reader::new(NsReader::from_reader(src.as_bytes())).await.unwrap();
+ let got = rdr.find::<Multistatus::<Core, PropValue<Core>>>().await.unwrap();
+ }
+
}