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-Match is evaluated first. A failed If-Match answers 412 whatever the method. A failed If-None-Match answers 304 to a GET and 412 otherwise.

Parameters:

version – The version of the resource, or None when the service does not version its resources. Such a resource matches no listed tag, and “*” still matches it (RFC 9110 §13.1.1).

Returns:

False when 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-Match or an If-None-Match header.

tags: frozenset[str] = frozenset({})#

The opaque part of each listed tag.

any: bool = False#

Whether the header is “*”, which matches any current representation.

classmethod parse(header: str | None) → EntityTags | None[source]#

Read the value of a conditional header.

Returns:

None when 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-Match and If-None-Match use the weak comparison (RFC 9110 §8.8.3.2).

Parameters:

version – The version of the resource, or None when the service does not version its resources.