Sets the content and caching headers on the response. .. versionadded:: 3.1
(self)
| 2886 | return f'"{version_hash}"' |
| 2887 | |
| 2888 | def set_headers(self) -> None: |
| 2889 | """Sets the content and caching headers on the response. |
| 2890 | |
| 2891 | .. versionadded:: 3.1 |
| 2892 | """ |
| 2893 | self.set_header("Accept-Ranges", "bytes") |
| 2894 | self.set_etag_header() |
| 2895 | |
| 2896 | if self.modified is not None: |
| 2897 | self.set_header("Last-Modified", self.modified) |
| 2898 | |
| 2899 | content_type = self.get_content_type() |
| 2900 | if content_type: |
| 2901 | self.set_header("Content-Type", content_type) |
| 2902 | |
| 2903 | cache_time = self.get_cache_time(self.path, self.modified, content_type) |
| 2904 | if cache_time > 0: |
| 2905 | self.set_header( |
| 2906 | "Expires", |
| 2907 | datetime.datetime.now(datetime.timezone.utc) |
| 2908 | + datetime.timedelta(seconds=cache_time), |
| 2909 | ) |
| 2910 | self.set_header("Cache-Control", "max-age=" + str(cache_time)) |
| 2911 | |
| 2912 | self.set_extra_headers(self.path) |
| 2913 | |
| 2914 | def should_return_304(self) -> bool: |
| 2915 | """Returns True if the headers indicate that we should return 304. |
no test coverage detected