mirror of https://github.com/django/django.git
Refs #28965 -- Removed utils.http.cookie_date() per deprecation timeline.
This commit is contained in:
parent
6f23996a59
commit
958a7b4ca6
|
@ -3,7 +3,6 @@ import calendar
|
|||
import datetime
|
||||
import re
|
||||
import unicodedata
|
||||
import warnings
|
||||
from binascii import Error as BinasciiError
|
||||
from email.utils import formatdate
|
||||
from urllib.parse import (
|
||||
|
@ -14,7 +13,6 @@ from urllib.parse import (
|
|||
|
||||
from django.core.exceptions import TooManyFieldsSent
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.deprecation import RemovedInDjango30Warning
|
||||
from django.utils.functional import keep_lazy_text
|
||||
|
||||
# based on RFC 7232, Appendix C
|
||||
|
@ -120,25 +118,6 @@ def urlencode(query, doseq=False):
|
|||
return original_urlencode(query_params, doseq)
|
||||
|
||||
|
||||
def cookie_date(epoch_seconds=None):
|
||||
"""
|
||||
Format the time to ensure compatibility with Netscape's cookie standard.
|
||||
|
||||
`epoch_seconds` is a floating point number expressed in seconds since the
|
||||
epoch, in UTC - such as that outputted by time.time(). If set to None, it
|
||||
defaults to the current time.
|
||||
|
||||
Output a string in the format 'Wdy, DD-Mon-YYYY HH:MM:SS GMT'.
|
||||
"""
|
||||
warnings.warn(
|
||||
'cookie_date() is deprecated in favor of http_date(), which follows '
|
||||
'the format of the latest RFC.',
|
||||
RemovedInDjango30Warning, stacklevel=2,
|
||||
)
|
||||
rfcdate = formatdate(epoch_seconds)
|
||||
return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25])
|
||||
|
||||
|
||||
def http_date(epoch_seconds=None):
|
||||
"""
|
||||
Format the time to match the RFC1123 date format as specified by HTTP
|
||||
|
|
|
@ -700,20 +700,6 @@ escaping HTML.
|
|||
A version of Python's :func:`urllib.parse.urlencode` function that can
|
||||
operate on ``MultiValueDict`` and non-string values.
|
||||
|
||||
.. function:: cookie_date(epoch_seconds=None)
|
||||
|
||||
.. deprecated:: 2.1
|
||||
|
||||
Use :func:`http_date` instead, which follows the latest RFC.
|
||||
|
||||
Formats the time to ensure compatibility with Netscape's cookie standard.
|
||||
|
||||
Accepts a floating point number expressed in seconds since the epoch in
|
||||
UTC--such as that outputted by ``time.time()``. If set to ``None``,
|
||||
defaults to the current time.
|
||||
|
||||
Outputs a string in the format ``Wdy, DD-Mon-YYYY HH:MM:SS GMT``.
|
||||
|
||||
.. function:: http_date(epoch_seconds=None)
|
||||
|
||||
Formats the time to match the :rfc:`1123` date format as specified by HTTP
|
||||
|
|
|
@ -254,3 +254,5 @@ See :ref:`deprecated-features-2.1` for details on these changes, including how
|
|||
to remove usage of these features.
|
||||
|
||||
* The ``ForceRHR`` GIS function is removed.
|
||||
|
||||
* ``django.utils.http.cookie_date()`` is removed.
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import unittest
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.deprecation import RemovedInDjango30Warning
|
||||
from django.utils.http import (
|
||||
base36_to_int, cookie_date, escape_leading_slashes, http_date,
|
||||
int_to_base36, is_safe_url, is_same_domain, parse_etags, parse_http_date,
|
||||
quote_etag, urlencode, urlquote, urlquote_plus, urlsafe_base64_decode,
|
||||
base36_to_int, escape_leading_slashes, http_date, int_to_base36,
|
||||
is_safe_url, is_same_domain, parse_etags, parse_http_date, quote_etag,
|
||||
urlencode, urlquote, urlquote_plus, urlsafe_base64_decode,
|
||||
urlsafe_base64_encode, urlunquote, urlunquote_plus,
|
||||
)
|
||||
|
||||
|
@ -279,11 +278,6 @@ class HttpDateProcessingTests(unittest.TestCase):
|
|||
t = 1167616461.0
|
||||
self.assertEqual(http_date(t), 'Mon, 01 Jan 2007 01:54:21 GMT')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango30Warning)
|
||||
def test_cookie_date(self):
|
||||
t = 1167616461.0
|
||||
self.assertEqual(cookie_date(t), 'Mon, 01-Jan-2007 01:54:21 GMT')
|
||||
|
||||
def test_parsing_rfc1123(self):
|
||||
parsed = parse_http_date('Sun, 06 Nov 1994 08:49:37 GMT')
|
||||
self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37))
|
||||
|
|
Loading…
Reference in New Issue