]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
httputil: Remove deprecated interfaces
authorBen Darnell <ben@bendarnell.com>
Sat, 7 Jul 2018 02:37:28 +0000 (22:37 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 14 Jul 2018 20:58:48 +0000 (16:58 -0400)
tornado/httputil.py

index 3961446694f7817109dea9319a75b872ea48209b..48c545ed57bf4b5adade12c30b53cbdd2df24753 100644 (file)
@@ -26,45 +26,25 @@ import collections
 import copy
 import datetime
 import email.utils
+from http.client import responses
+import http.cookies as Cookie
 import numbers
 import re
+from ssl import SSLError
 import time
 import unicodedata
-import warnings
+from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
 
 from tornado.escape import native_str, parse_qs_bytes, utf8
 from tornado.log import gen_log
-from tornado.util import ObjectDict, PY3, unicode_type
-
-if PY3:
-    import http.cookies as Cookie
-    from http.client import responses
-    from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
-else:
-    import Cookie
-    from httplib import responses
-    from urllib import urlencode
-    from urlparse import urlparse, urlunparse, parse_qsl
+from tornado.util import ObjectDict, unicode_type
 
 
 # responses is unused in this file, but we re-export it to other files.
 # Reference it so pyflakes doesn't complain.
 responses
 
-try:
-    from ssl import SSLError
-except ImportError:
-    # ssl is unavailable on app engine.
-    class _SSLError(Exception):
-        pass
-    # Hack around a mypy limitation. We can't simply put "type: ignore"
-    # on the class definition itself; must go through an assignment.
-    SSLError = _SSLError  # type: ignore
-
-try:
-    import typing  # noqa: F401
-except ImportError:
-    pass
+import typing  # noqa: F401
 
 
 # RFC 7230 section 3.5: a recipient MAY recognize a single LF as a line
@@ -378,21 +358,6 @@ class HTTPServerRequest(object):
         self.query_arguments = copy.deepcopy(self.arguments)
         self.body_arguments = {}
 
-    def supports_http_1_1(self):
-        """Returns True if this request supports HTTP/1.1 semantics.
-
-        .. deprecated:: 4.0
-
-           Applications are less likely to need this information with
-           the introduction of `.HTTPConnection`. If you still need
-           it, access the ``version`` attribute directly. This method
-           will be removed in Tornado 6.0.
-
-        """
-        warnings.warn("supports_http_1_1() is deprecated, use request.version instead",
-                      DeprecationWarning)
-        return self.version == "HTTP/1.1"
-
     @property
     def cookies(self):
         """A dictionary of Cookie.Morsel objects."""
@@ -414,32 +379,6 @@ class HTTPServerRequest(object):
                             pass
         return self._cookies
 
-    def write(self, chunk, callback=None):
-        """Writes the given chunk to the response stream.
-
-        .. deprecated:: 4.0
-           Use ``request.connection`` and the `.HTTPConnection` methods
-           to write the response. This method will be removed in Tornado 6.0.
-        """
-        warnings.warn("req.write deprecated, use req.connection.write and write_headers instead",
-                      DeprecationWarning)
-        assert isinstance(chunk, bytes)
-        assert self.version.startswith("HTTP/1."), \
-            "deprecated interface only supported in HTTP/1.x"
-        self.connection.write(chunk, callback=callback)
-
-    def finish(self):
-        """Finishes this HTTP request on the open connection.
-
-        .. deprecated:: 4.0
-           Use ``request.connection`` and the `.HTTPConnection` methods
-           to write the response. This method will be removed in Tornado 6.0.
-        """
-        warnings.warn("req.finish deprecated, use req.connection.finish instead",
-                      DeprecationWarning)
-        self.connection.finish()
-        self._finish_time = time.time()
-
     def full_url(self):
         """Reconstructs the full URL for this request."""
         return self.protocol + "://" + self.host + self.uri
@@ -579,7 +518,7 @@ class HTTPConnection(object):
 
     .. versionadded:: 4.0
     """
-    def write_headers(self, start_line, headers, chunk=None, callback=None):
+    def write_headers(self, start_line, headers, chunk=None):
         """Write an HTTP header block.
 
         :arg start_line: a `.RequestStartLine` or `.ResponseStartLine`.
@@ -593,23 +532,21 @@ class HTTPConnection(object):
 
         Returns a `.Future` if no callback is given.
 
-        .. deprecated:: 5.1
+        .. versionchanged:: 6.0
 
-           The ``callback`` argument is deprecated and will be removed
-           in Tornado 6.0.
+           The ``callback`` argument was removed.
         """
         raise NotImplementedError()
 
-    def write(self, chunk, callback=None):
+    def write(self, chunk):
         """Writes a chunk of body data.
 
         The callback will be run when the write is complete.  If no callback
         is given, returns a Future.
 
-        .. deprecated:: 5.1
+        .. versionchanged:: 6.0
 
-           The ``callback`` argument is deprecated and will be removed
-           in Tornado 6.0.
+           The ``callback`` argument was removed.
         """
         raise NotImplementedError()