feat: add webdav proppatch handler (#18)
parent
916602ae2d
commit
5578ee9190
|
@ -251,7 +251,7 @@ impl InnerService {
|
||||||
}
|
}
|
||||||
"PROPPATCH" => {
|
"PROPPATCH" => {
|
||||||
if is_file {
|
if is_file {
|
||||||
self.handle_propfind_file(path, &mut res).await?;
|
self.handle_proppatch(req_path, &mut res).await?;
|
||||||
} else {
|
} else {
|
||||||
status!(res, StatusCode::NOT_FOUND);
|
status!(res, StatusCode::NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -533,13 +533,13 @@ impl InnerService {
|
||||||
acc.push_str(&v);
|
acc.push_str(&v);
|
||||||
acc
|
acc
|
||||||
});
|
});
|
||||||
res_propfind(res, &output);
|
res_multistatus(res, &output);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_propfind_file(&self, path: &Path, res: &mut Response) -> BoxResult<()> {
|
async fn handle_propfind_file(&self, path: &Path, res: &mut Response) -> BoxResult<()> {
|
||||||
if let Some(pathitem) = self.to_pathitem(path, &self.args.path).await? {
|
if let Some(pathitem) = self.to_pathitem(path, &self.args.path).await? {
|
||||||
res_propfind(res, &pathitem.to_dav_xml(self.args.uri_prefix.as_str()));
|
res_multistatus(res, &pathitem.to_dav_xml(self.args.uri_prefix.as_str()));
|
||||||
} else {
|
} else {
|
||||||
status!(res, StatusCode::NOT_FOUND);
|
status!(res, StatusCode::NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -627,6 +627,22 @@ impl InnerService {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn handle_proppatch(&self, req_path: &str, res: &mut Response) -> BoxResult<()> {
|
||||||
|
let output = format!(
|
||||||
|
r#"<D:response>
|
||||||
|
<D:href>{}</D:href>
|
||||||
|
<D:propstat>
|
||||||
|
<D:prop>
|
||||||
|
</D:prop>
|
||||||
|
<D:status>HTTP/1.1 403 Forbidden</D:status>
|
||||||
|
</D:propstat>
|
||||||
|
</D:response>"#,
|
||||||
|
req_path
|
||||||
|
);
|
||||||
|
res_multistatus(res, &output);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn send_index(
|
fn send_index(
|
||||||
&self,
|
&self,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
|
@ -882,7 +898,7 @@ fn add_cors(res: &mut Response) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn res_propfind(res: &mut Response, content: &str) {
|
fn res_multistatus(res: &mut Response, content: &str) {
|
||||||
*res.status_mut() = StatusCode::MULTI_STATUS;
|
*res.status_mut() = StatusCode::MULTI_STATUS;
|
||||||
res.headers_mut().insert(
|
res.headers_mut().insert(
|
||||||
"content-type",
|
"content-type",
|
||||||
|
|
Loading…
Reference in New Issue