Returns True if the headers indicate that we should return 304. .. versionadded:: 3.1
(self)
| 2727 | self.set_extra_headers(self.path) |
| 2728 | |
| 2729 | def should_return_304(self) -> bool: |
| 2730 | """Returns True if the headers indicate that we should return 304. |
| 2731 | |
| 2732 | .. versionadded:: 3.1 |
| 2733 | """ |
| 2734 | # If client sent If-None-Match, use it, ignore If-Modified-Since |
| 2735 | if self.request.headers.get("If-None-Match"): |
| 2736 | return self.check_etag_header() |
| 2737 | |
| 2738 | # Check the If-Modified-Since, and don't send the result if the |
| 2739 | # content has not been modified |
| 2740 | ims_value = self.request.headers.get("If-Modified-Since") |
| 2741 | if ims_value is not None: |
| 2742 | date_tuple = email.utils.parsedate(ims_value) |
| 2743 | if date_tuple is not None: |
| 2744 | if_since = datetime.datetime(*date_tuple[:6]) |
| 2745 | assert self.modified is not None |
| 2746 | if if_since >= self.modified: |
| 2747 | return True |
| 2748 | |
| 2749 | return False |
| 2750 | |
| 2751 | @classmethod |
| 2752 | def get_absolute_path(cls, root: str, path: str) -> str: |
no test coverage detected