aboutsummaryrefslogtreecommitdiff
path: root/aero-proto/src/dav
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 09:57:34 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 09:57:34 +0200
commit06a24bb5598226edcedaaa1e3ba122ef6a40a793 (patch)
tree4b3e59e3c0a9721e34db8c9295e082d4f62d3b22 /aero-proto/src/dav
parent3a8b45a0b1d96fb404267956c3cb723ad7d99339 (diff)
downloadaerogramme-06a24bb5598226edcedaaa1e3ba122ef6a40a793.tar.gz
aerogramme-06a24bb5598226edcedaaa1e3ba122ef6a40a793.zip
fix DAV header for iOS
Diffstat (limited to 'aero-proto/src/dav')
-rw-r--r--aero-proto/src/dav/controller.rs14
-rw-r--r--aero-proto/src/dav/mod.rs9
-rw-r--r--aero-proto/src/dav/node.rs4
-rw-r--r--aero-proto/src/dav/resource.rs23
4 files changed, 41 insertions, 9 deletions
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::<All> {
+ let multistatus = dav::Multistatus::<All> {
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<hyper::body::Incoming>| {
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<All>;
/// Get the values for the given properties
fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> PropertyStream<'static>;
- //fn properties(&self, user: &ArcUser, prop: dav::PropName<All>) -> Vec<dav::AnyProperty<All>>;
+ /// 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()
+ }
}