mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
refactor: make logout works on safari (#442)
This commit is contained in:
@@ -429,7 +429,8 @@ fn is_readonly_method(method: &Method) -> bool {
|
||||
|| method == Method::OPTIONS
|
||||
|| method == Method::HEAD
|
||||
|| method.as_str() == "PROPFIND"
|
||||
|| method.as_str() == "AUTH"
|
||||
|| method.as_str() == "CHECKAUTH"
|
||||
|| method.as_str() == "LOGOUT"
|
||||
}
|
||||
|
||||
fn strip_prefix<'a>(search: &'a [u8], prefix: &[u8]) -> Option<&'a [u8]> {
|
||||
|
||||
@@ -200,11 +200,17 @@ impl Server {
|
||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||
.collect();
|
||||
|
||||
if method.as_str() == "AUTH" {
|
||||
if user.is_none() {
|
||||
self.auth_reject(&mut res)?;
|
||||
if method.as_str() == "CHECKAUTH" {
|
||||
match user.clone() {
|
||||
Some(user) => {
|
||||
*res.body_mut() = body_full(user);
|
||||
}
|
||||
None => self.auth_reject(&mut res)?,
|
||||
}
|
||||
return Ok(res);
|
||||
} else if method.as_str() == "LOGOUT" {
|
||||
self.auth_reject(&mut res)?;
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
let head_only = method == Method::HEAD;
|
||||
@@ -1722,7 +1728,9 @@ fn is_hidden(hidden: &[String], file_name: &str, is_dir_type: bool) -> bool {
|
||||
fn set_webdav_headers(res: &mut Response) {
|
||||
res.headers_mut().insert(
|
||||
"Allow",
|
||||
HeaderValue::from_static("GET,HEAD,PUT,OPTIONS,DELETE,PATCH,PROPFIND,COPY,MOVE"),
|
||||
HeaderValue::from_static(
|
||||
"GET,HEAD,PUT,OPTIONS,DELETE,PATCH,PROPFIND,COPY,MOVE,CHECKAUTH,LOGOUT",
|
||||
),
|
||||
);
|
||||
res.headers_mut()
|
||||
.insert("DAV", HeaderValue::from_static("1, 2, 3"));
|
||||
|
||||
Reference in New Issue
Block a user