MCPcopy Create free account
hub / github.com/EasyIME/PIME / set_headers

Method set_headers

python/python3/tornado/web.py:2704–2727  ·  view source on GitHub ↗

Sets the content and caching headers on the response. .. versionadded:: 3.1

(self)

Source from the content-addressed store, hash-verified

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.

Callers 1

getMethod · 0.95

Calls 5

get_content_typeMethod · 0.95
get_cache_timeMethod · 0.95
set_extra_headersMethod · 0.95
set_headerMethod · 0.80
set_etag_headerMethod · 0.80

Tested by

no test coverage detected