diff --git a/aero-proto/src/dav/controller.rs b/aero-proto/src/dav/controller.rs index 76dd15d..8c53c6b 100644 --- a/aero-proto/src/dav/controller.rs +++ b/aero-proto/src/dav/controller.rs @@ -61,18 +61,19 @@ impl Controller { } }; + let dav_hdrs = node.dav_header(); let ctrl = Self { node, user, req }; match method.as_str() { "OPTIONS" => Ok(Response::builder() .status(200) - .header("DAV", "1") + .header("DAV", dav_hdrs) .header("Allow", "HEAD,GET,PUT,OPTIONS,DELETE,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MKCALENDAR,REPORT") .body(codec::text_body(""))?), "HEAD" => { - tracing::warn!("HEAD not correctly implemented"); + tracing::warn!("HEAD might not correctly implemented: should return ETags & co"); Ok(Response::builder() - .status(404) + .status(200) .body(codec::text_body(""))?) }, "GET" => ctrl.get().await, @@ -348,11 +349,14 @@ impl Controller { } // Build response - dav::Multistatus:: { + let multistatus = dav::Multistatus:: { responses, responsedescription: None, extension, - } + }; + + tracing::debug!(multistatus=?multistatus, "multistatus response"); + multistatus } } diff --git a/aero-proto/src/dav/mod.rs b/aero-proto/src/dav/mod.rs index 43de3a5..a3dd58d 100644 --- a/aero-proto/src/dav/mod.rs +++ b/aero-proto/src/dav/mod.rs @@ -98,7 +98,7 @@ impl Server { let conn = tokio::spawn(async move { //@FIXME should create a generic "public web" server on which "routers" could be //abitrarily bound - //@FIXME replace with a handler supporting http2 and TLS + //@FIXME replace with a handler supporting http2 match http::Builder::new() .serve_connection( @@ -106,8 +106,9 @@ impl Server { service_fn(|req: Request| { let login = login.clone(); tracing::info!("{:?} {:?}", req.method(), req.uri()); + tracing::debug!(req=?req, "full request"); async { - match middleware::auth(login, req, |user, request| { + let response = match middleware::auth(login, req, |user, request| { async { Controller::route(user, request).await }.boxed() }) .await @@ -119,7 +120,9 @@ impl Server { .status(500) .body(codec::text_body("Internal error")) } - } + }; + tracing::debug!(resp=?response, "full response"); + response } }), ) diff --git a/aero-proto/src/dav/node.rs b/aero-proto/src/dav/node.rs index 0a83f8c..3af3b81 100644 --- a/aero-proto/src/dav/node.rs +++ b/aero-proto/src/dav/node.rs @@ -40,7 +40,9 @@ pub(crate) trait DavNode: Send { fn supported_properties(&self, user: &ArcUser) -> dav::PropName; /// Get the values for the given properties fn properties(&self, user: &ArcUser, prop: dav::PropName) -> PropertyStream<'static>; - //fn properties(&self, user: &ArcUser, prop: dav::PropName) -> Vec>; + /// Get the value of the DAV header to return + fn dav_header(&self) -> String; + /// Put an element (create or update) fn put<'a>( &'a self, diff --git a/aero-proto/src/dav/resource.rs b/aero-proto/src/dav/resource.rs index b6c0ed5..b5ae029 100644 --- a/aero-proto/src/dav/resource.rs +++ b/aero-proto/src/dav/resource.rs @@ -139,6 +139,10 @@ impl DavNode for RootNode { > { async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed() } + + fn dav_header(&self) -> String { + "1".into() + } } #[derive(Clone)] @@ -260,6 +264,10 @@ impl DavNode for HomeNode { > { async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed() } + + fn dav_header(&self) -> String { + "1, access-control, calendar-access".into() + } } #[derive(Clone)] @@ -393,6 +401,10 @@ impl DavNode for CalendarListNode { > { async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed() } + + fn dav_header(&self) -> String { + "1, access-control, calendar-access".into() + } } #[derive(Clone)] @@ -641,6 +653,9 @@ impl DavNode for CalendarNode { } .boxed() } + fn dav_header(&self) -> String { + "1, access-control, calendar-access".into() + } } #[derive(Clone)] @@ -872,6 +887,10 @@ impl DavNode for EventNode { > { async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed() } + + fn dav_header(&self) -> String { + "1, access-control".into() + } } #[derive(Clone)] @@ -973,4 +992,8 @@ impl DavNode for CreateEventNode { > { async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed() } + + fn dav_header(&self) -> String { + "1, access-control".into() + } }