strict_preconditions: new config option / handling

This commit is contained in:
Peter Bieringer
2025-10-19 18:55:36 +02:00
parent ea1df00161
commit c503542c6c
2 changed files with 6 additions and 0 deletions

View File

@@ -207,6 +207,9 @@ class ApplicationPartPut(ApplicationBase):
return httputils.NOT_ALLOWED
etag = environ.get("HTTP_IF_MATCH", "")
if item and not etag and self._strict_preconditions:
logger.warning("Precondition failed for %r: existing item, no If-Match header, strict mode enabled", path)
return httputils.PRECONDITION_FAILED
if not item and etag:
# Etag asked but no item found: item has been removed
logger.warning("Precondition failed on PUT request for %r (HTTP_IF_MATCH: %s, item not existing)", path, etag)