本文整理汇总了Python中django.http.HttpResponseNotModified.cookies方法的典型用法代码示例。如果您正苦于以下问题:Python HttpResponseNotModified.cookies方法的具体用法?Python HttpResponseNotModified.cookies怎么用?Python HttpResponseNotModified.cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.HttpResponseNotModified
的用法示例。
在下文中一共展示了HttpResponseNotModified.cookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _not_modified
# 需要导入模块: from django.http import HttpResponseNotModified [as 别名]
# 或者: from django.http.HttpResponseNotModified import cookies [as 别名]
def _not_modified(request, response=None):
if response:
# We need to keep the cookies, see ticket #4994.
cookies = response.cookies
response = HttpResponseNotModified()
response.cookies = cookies
return response
else:
return HttpResponseNotModified()
示例2: _not_modified
# 需要导入模块: from django.http import HttpResponseNotModified [as 别名]
# 或者: from django.http.HttpResponseNotModified import cookies [as 别名]
def _not_modified(request, response=None):
new_response = HttpResponseNotModified()
if response:
# Preserve the headers required by Section 4.1 of RFC 7232, as well as
# Last-Modified.
for header in ('Cache-Control', 'Content-Location', 'Date', 'ETag', 'Expires', 'Last-Modified', 'Vary'):
if header in response:
new_response[header] = response[header]
# Preserve cookies as per the cookie specification: "If a proxy server
# receives a response which contains a Set-cookie header, it should
# propagate the Set-cookie header to the client, regardless of whether
# the response was 304 (Not Modified) or 200 (OK).
# https://curl.haxx.se/rfc/cookie_spec.html
new_response.cookies = response.cookies
return new_response
示例3:
# 需要导入模块: from django.http import HttpResponseNotModified [as 别名]
# 或者: from django.http.HttpResponseNotModified import cookies [as 别名]
"""