WebDAV: Return 304 NOT_MODIFIED on If-None-Match

This commit is contained in:
mdecimus
2026-02-26 19:39:06 +01:00
parent 620ab2a9bc
commit 2266634f36
2 changed files with 24 additions and 4 deletions

View File

@@ -5,18 +5,18 @@
*/
use super::{
Collation, MatchType,
property::{DavProperty, DavValue, LockScope, LockType},
response::Ace,
Collation, MatchType,
};
use crate::Depth;
use crate::{Condition, Depth};
use calcard::{
icalendar::{ICalendarComponentType, ICalendarParameterName, ICalendarProperty},
vcard::{VCardParameterName, VCardProperty},
};
use types::{
dead_property::{ArchivedDeadProperty, ArchivedDeadPropertyTag, DeadElementTag, DeadProperty},
TimeRange,
dead_property::{ArchivedDeadProperty, ArchivedDeadPropertyTag, DeadElementTag, DeadProperty},
};
#[derive(Debug, Clone, PartialEq, Eq, Default)]
@@ -284,3 +284,12 @@ impl DavDeadProperty for ArchivedDeadProperty {
}
}
}
impl Condition<'_> {
pub fn is_none_match(&self) -> bool {
match self {
Condition::ETag { is_not, .. } | Condition::Exists { is_not } => *is_not,
Condition::StateToken { .. } => false,
}
}
}

View File

@@ -605,7 +605,18 @@ impl LockRequestHandler for Server {
return lock_response;
}
Err(DavError::Code(StatusCode::PRECONDITION_FAILED))
Err(DavError::Code(
if matches!(method, DavMethod::GET | DavMethod::HEAD)
&& headers
.if_
.iter()
.any(|if_| if_.list.iter().any(|cond| cond.is_none_match()))
{
StatusCode::NOT_MODIFIED
} else {
StatusCode::PRECONDITION_FAILED
},
))
}
}