Test the If-Match comparison as defined in RFC 9110 Section 13.1.1.
(target_etag, etags)
| 213 | |
| 214 | |
| 215 | def _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 | |
| 236 | def _if_unmodified_since_passes(last_modified, if_unmodified_since): |
no outgoing calls
no test coverage detected