Sets the content and caching headers on the response. .. versionadded:: 3.1
(self)
| 2702 | return '"%s"' % (version_hash,) |
| 2703 | |
| 2704 | def set_headers(self) -> None: |
| 2705 | """Sets the content and caching headers on the response. |
| 2706 | |
| 2707 | .. versionadded:: 3.1 |
| 2708 | """ |
| 2709 | self.set_header("Accept-Ranges", "bytes") |
| 2710 | self.set_etag_header() |
| 2711 | |
| 2712 | if self.modified is not None: |
| 2713 | self.set_header("Last-Modified", self.modified) |
| 2714 | |
| 2715 | content_type = self.get_content_type() |
| 2716 | if content_type: |
| 2717 | self.set_header("Content-Type", content_type) |
| 2718 | |
| 2719 | cache_time = self.get_cache_time(self.path, self.modified, content_type) |
| 2720 | if cache_time > 0: |
| 2721 | self.set_header( |
| 2722 | "Expires", |
| 2723 | datetime.datetime.utcnow() + datetime.timedelta(seconds=cache_time), |
| 2724 | ) |
| 2725 | self.set_header("Cache-Control", "max-age=" + str(cache_time)) |
| 2726 | |
| 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. |
no test coverage detected