MCPcopy
hub / github.com/django/django / _pre_process_request

Function _pre_process_request

django/views/decorators/http.py:106–122  ·  view source on GitHub ↗
(request, *args, **kwargs)

Source from the content-addressed store, hash-verified

104
105 def decorator(func):
106 def _pre_process_request(request, *args, **kwargs):
107 # Compute values (if any) for the requested resource.
108 res_last_modified = None
109 if last_modified_func:
110 if dt := last_modified_func(request, *args, **kwargs):
111 if not timezone.is_aware(dt):
112 dt = timezone.make_aware(dt, datetime.UTC)
113 res_last_modified = int(dt.timestamp())
114 # The value from etag_func() could be quoted or unquoted.
115 res_etag = etag_func(request, *args, **kwargs) if etag_func else None
116 res_etag = quote_etag(res_etag) if res_etag is not None else None
117 response = get_conditional_response(
118 request,
119 etag=res_etag,
120 last_modified=res_last_modified,
121 )
122 return response, res_etag, res_last_modified
123
124 def _post_process_request(request, response, res_etag, res_last_modified):
125 # Set relevant headers on the response if they don't already exist

Callers 1

innerFunction · 0.70

Calls 3

quote_etagFunction · 0.90
get_conditional_responseFunction · 0.90
timestampMethod · 0.80

Tested by

no test coverage detected