Test the If-None-Match comparison as defined in RFC 9110 Section 13.1.2.
(target_etag, etags)
| 242 | |
| 243 | |
| 244 | def _if_none_match_passes(target_etag, etags): |
| 245 | """ |
| 246 | Test the If-None-Match comparison as defined in RFC 9110 Section 13.1.2. |
| 247 | """ |
| 248 | if not target_etag: |
| 249 | # If there isn't an ETag, then there isn't a match. |
| 250 | return True |
| 251 | elif etags == ["*"]: |
| 252 | # The existence of an ETag means that there is "a current |
| 253 | # representation for the target resource", so there is a match to '*'. |
| 254 | return False |
| 255 | else: |
| 256 | # The comparison should be weak, so look for a match after stripping |
| 257 | # off any weak indicators. |
| 258 | target_etag = target_etag.strip("W/") |
| 259 | etags = (etag.strip("W/") for etag in etags) |
| 260 | return target_etag not in etags |
| 261 | |
| 262 | |
| 263 | def _if_modified_since_passes(last_modified, if_modified_since): |
no outgoing calls
no test coverage detected