MCPcopy
hub / github.com/django/django / _if_match_passes

Function _if_match_passes

django/utils/cache.py:215–233  ·  view source on GitHub ↗

Test the If-Match comparison as defined in RFC 9110 Section 13.1.1.

(target_etag, etags)

Source from the content-addressed store, hash-verified

213
214
215def _if_match_passes(target_etag, etags):
216 """
217 Test the If-Match comparison as defined in RFC 9110 Section 13.1.1.
218 """
219 if not target_etag:
220 # If there isn't an ETag, then there can't be a match.
221 return False
222 elif etags == ["*"]:
223 # The existence of an ETag means that there is "a current
224 # representation for the target resource", even if the ETag is weak,
225 # so there is a match to '*'.
226 return True
227 elif target_etag.startswith("W/"):
228 # A weak ETag can never strongly match another ETag.
229 return False
230 else:
231 # Since the ETag is strong, this will only return True if there's a
232 # strong match.
233 return target_etag in etags
234
235
236def _if_unmodified_since_passes(last_modified, if_unmodified_since):

Callers 1

get_conditional_responseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected