fix DAV header for iOS
This commit is contained in:
parent
3a8b45a0b1
commit
06a24bb559
4 changed files with 41 additions and 9 deletions
|
@ -61,18 +61,19 @@ impl Controller {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dav_hdrs = node.dav_header();
|
||||||
let ctrl = Self { node, user, req };
|
let ctrl = Self { node, user, req };
|
||||||
|
|
||||||
match method.as_str() {
|
match method.as_str() {
|
||||||
"OPTIONS" => Ok(Response::builder()
|
"OPTIONS" => Ok(Response::builder()
|
||||||
.status(200)
|
.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")
|
.header("Allow", "HEAD,GET,PUT,OPTIONS,DELETE,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,MKCALENDAR,REPORT")
|
||||||
.body(codec::text_body(""))?),
|
.body(codec::text_body(""))?),
|
||||||
"HEAD" => {
|
"HEAD" => {
|
||||||
tracing::warn!("HEAD not correctly implemented");
|
tracing::warn!("HEAD might not correctly implemented: should return ETags & co");
|
||||||
Ok(Response::builder()
|
Ok(Response::builder()
|
||||||
.status(404)
|
.status(200)
|
||||||
.body(codec::text_body(""))?)
|
.body(codec::text_body(""))?)
|
||||||
},
|
},
|
||||||
"GET" => ctrl.get().await,
|
"GET" => ctrl.get().await,
|
||||||
|
@ -348,11 +349,14 @@ impl Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build response
|
// Build response
|
||||||
dav::Multistatus::<All> {
|
let multistatus = dav::Multistatus::<All> {
|
||||||
responses,
|
responses,
|
||||||
responsedescription: None,
|
responsedescription: None,
|
||||||
extension,
|
extension,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
tracing::debug!(multistatus=?multistatus, "multistatus response");
|
||||||
|
multistatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl Server {
|
||||||
let conn = tokio::spawn(async move {
|
let conn = tokio::spawn(async move {
|
||||||
//@FIXME should create a generic "public web" server on which "routers" could be
|
//@FIXME should create a generic "public web" server on which "routers" could be
|
||||||
//abitrarily bound
|
//abitrarily bound
|
||||||
//@FIXME replace with a handler supporting http2 and TLS
|
//@FIXME replace with a handler supporting http2
|
||||||
|
|
||||||
match http::Builder::new()
|
match http::Builder::new()
|
||||||
.serve_connection(
|
.serve_connection(
|
||||||
|
@ -106,8 +106,9 @@ impl Server {
|
||||||
service_fn(|req: Request<hyper::body::Incoming>| {
|
service_fn(|req: Request<hyper::body::Incoming>| {
|
||||||
let login = login.clone();
|
let login = login.clone();
|
||||||
tracing::info!("{:?} {:?}", req.method(), req.uri());
|
tracing::info!("{:?} {:?}", req.method(), req.uri());
|
||||||
|
tracing::debug!(req=?req, "full request");
|
||||||
async {
|
async {
|
||||||
match middleware::auth(login, req, |user, request| {
|
let response = match middleware::auth(login, req, |user, request| {
|
||||||
async { Controller::route(user, request).await }.boxed()
|
async { Controller::route(user, request).await }.boxed()
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
@ -119,7 +120,9 @@ impl Server {
|
||||||
.status(500)
|
.status(500)
|
||||||
.body(codec::text_body("Internal error"))
|
.body(codec::text_body("Internal error"))
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
tracing::debug!(resp=?response, "full response");
|
||||||
|
response
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,7 +40,9 @@ pub(crate) trait DavNode: Send {
|
||||||
fn supported_properties(&self, user: &ArcUser) -> dav::PropName<All>;
|
fn supported_properties(&self, user: &ArcUser) -> dav::PropName<All>;
|
||||||
/// Get the values for the given properties
|
/// 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>) -> 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)
|
/// Put an element (create or update)
|
||||||
fn put<'a>(
|
fn put<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
|
@ -139,6 +139,10 @@ impl DavNode for RootNode {
|
||||||
> {
|
> {
|
||||||
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -260,6 +264,10 @@ impl DavNode for HomeNode {
|
||||||
> {
|
> {
|
||||||
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1, access-control, calendar-access".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -393,6 +401,10 @@ impl DavNode for CalendarListNode {
|
||||||
> {
|
> {
|
||||||
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1, access-control, calendar-access".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -641,6 +653,9 @@ impl DavNode for CalendarNode {
|
||||||
}
|
}
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1, access-control, calendar-access".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -872,6 +887,10 @@ impl DavNode for EventNode {
|
||||||
> {
|
> {
|
||||||
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1, access-control".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -973,4 +992,8 @@ impl DavNode for CreateEventNode {
|
||||||
> {
|
> {
|
||||||
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
async { Err(std::io::Error::from(std::io::ErrorKind::Unsupported)) }.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dav_header(&self) -> String {
|
||||||
|
"1, access-control".into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue