Conditional requests#
The If-Match and If-None-Match headers of a request
(RFC 9110 §13.1).
- class scim2_server.conditions.Conditions(if_match: str | None = None, if_none_match: str | None = None)[source]#
The raw values of the conditional headers of a request.
- check(version: str | None, method: str) bool[source]#
Evaluate the conditions against the version of a resource.
Per RFC 9110 §13.2.2,
If-Matchis evaluated first. A failedIf-Matchanswers 412 whatever the method. A failedIf-None-Matchanswers 304 to a GET and 412 otherwise.- Parameters:
version – The version of the resource, or
Nonewhen the service does not version its resources. Such a resource matches no listed tag, and “*” still matches it (RFC 9110 §13.1.1).- Returns:
Falsewhen a GET should answer 304 Not Modified.- Raises:
PreconditionFailedException – When the method must not be performed.
- class scim2_server.conditions.EntityTags(tags: frozenset[str] = frozenset({}), any: bool = False)[source]#
The entity tags of an
If-Matchor anIf-None-Matchheader.- classmethod parse(header: str | None) EntityTags | None[source]#
Read the value of a conditional header.
- Returns:
Nonewhen the header is missing or empty.
- matches(version: str | None) bool[source]#
Tell whether a resource version matches the header, with the weak comparison.
Both
If-MatchandIf-None-Matchuse the weak comparison (RFC 9110 §8.8.3.2).- Parameters:
version – The version of the resource, or
Nonewhen the service does not version its resources.