From 1c6a5bb59abbe5b491d3401c3743c966977a814b Mon Sep 17 00:00:00 2001 From: JackDandy Date: Wed, 12 Apr 2023 14:10:23 +0100 Subject: [PATCH] =?UTF-8?q?Update=20Tornado=20Web=20Server=206.3.0=20(7186?= =?UTF-8?q?b86)=20=E2=86=92=206.3.1=20(419838b).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 3 ++- lib/tornado/__init__.py | 4 ++-- lib/tornado/web.py | 25 +++++++++++++++++++++---- lib/tornado/websocket.py | 18 +++++++++--------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bd5f9be3..83f7a7fc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ ### 3.29.0 (2023-xx-xx xx:xx:00 UTC) * Update SimpleJSON 3.18.1 (c891b95) to 3.19.1 (aeb63ee) +* Update Tornado Web Server 6.3.0 (7186b86) to 6.3.1 (419838b) ### 3.28.0 (2023-04-12 13:05:00 UTC) @@ -20,7 +21,7 @@ * Add optional "freespace" parameter to endpoints: sg.getrootdirs, sg.addrootdir, sg.deleterootdir * Change update help of affected endpoints * Fix explicitly save rootdirs after adding or deleting via Web API -* Change add Rarbg UHD search category +* Change add Rarbg UHD search category ### 3.27.13 (2023-04-12 10:15:00 UTC) diff --git a/lib/tornado/__init__.py b/lib/tornado/__init__.py index 060b836a..afbd7150 100644 --- a/lib/tornado/__init__.py +++ b/lib/tornado/__init__.py @@ -22,8 +22,8 @@ # is zero for an official release, positive for a development branch, # or negative for a release candidate or beta (after the base version # number has been incremented) -version = "6.3.dev1" -version_info = (6, 3, 0, -100) +version = "6.3.1" +version_info = (6, 3, 1, 0) import importlib import typing diff --git a/lib/tornado/web.py b/lib/tornado/web.py index 18634d89..3b676e3c 100644 --- a/lib/tornado/web.py +++ b/lib/tornado/web.py @@ -79,6 +79,7 @@ import socket import sys import threading import time +import warnings import tornado import traceback import types @@ -91,10 +92,8 @@ from tornado import gen from tornado.httpserver import HTTPServer from tornado import httputil from tornado import iostream -import tornado.locale from tornado import locale from tornado.log import access_log, app_log, gen_log -import tornado.netutil from tornado import template from tornado.escape import utf8, _unicode from tornado.routing import ( @@ -609,6 +608,7 @@ class RequestHandler(object): httponly: bool = False, secure: bool = False, samesite: Optional[str] = None, + **kwargs: Any, ) -> None: """Sets an outgoing cookie name/value with the given options. @@ -625,6 +625,10 @@ class RequestHandler(object): to set an expiration time in days from today (if both are set, ``expires`` is used). + .. deprecated:: 6.3 + Keyword arguments are currently accepted case-insensitively. + In Tornado 7.0 this will be changed to only accept lowercase + arguments. """ # The cookie library only accepts type str, in both python 2 and 3 name = escape.native_str(name) @@ -659,6 +663,17 @@ class RequestHandler(object): morsel["secure"] = True if samesite: morsel["samesite"] = samesite + if kwargs: + # The setitem interface is case-insensitive, so continue to support + # kwargs for backwards compatibility until we can remove deprecated + # features. + for k, v in kwargs.items(): + morsel[k] = v + warnings.warn( + f"Deprecated arguments to set_cookie: {set(kwargs.keys())} " + "(should be lowercase)", + DeprecationWarning, + ) def clear_cookie(self, name: str, **kwargs: Any) -> None: """Deletes the cookie with the given name. @@ -1486,7 +1501,8 @@ class RequestHandler(object): if version is None: if self.current_user and "expires_days" not in cookie_kwargs: cookie_kwargs["expires_days"] = 30 - self.set_cookie("_xsrf", self._xsrf_token, **cookie_kwargs) + cookie_name = self.settings.get("xsrf_cookie_name", "_xsrf") + self.set_cookie(cookie_name, self._xsrf_token, **cookie_kwargs) return self._xsrf_token def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]: @@ -1501,7 +1517,8 @@ class RequestHandler(object): for version 1 cookies) """ if not hasattr(self, "_raw_xsrf_token"): - cookie = self.get_cookie("_xsrf") + cookie_name = self.settings.get("xsrf_cookie_name", "_xsrf") + cookie = self.get_cookie(cookie_name) if cookie: version, token, timestamp = self._decode_xsrf_token(cookie) else: diff --git a/lib/tornado/websocket.py b/lib/tornado/websocket.py index 1d42e10b..d0abd425 100644 --- a/lib/tornado/websocket.py +++ b/lib/tornado/websocket.py @@ -1,16 +1,11 @@ """Implementation of the WebSocket protocol. `WebSockets `_ allow for bidirectional -communication between the browser and server. - -WebSockets are supported in the current versions of all major browsers, -although older versions that do not support WebSockets are still in use -(refer to http://caniuse.com/websockets for details). +communication between the browser and server. WebSockets are supported in the +current versions of all major browsers. This module implements the final version of the WebSocket protocol as -defined in `RFC 6455 `_. Certain -browser versions (notably Safari 5.x) implemented an earlier draft of -the protocol (known as "draft 76") and are not compatible with this module. +defined in `RFC 6455 `_. .. versionchanged:: 4.0 Removed support for the draft 76 protocol version. @@ -23,7 +18,7 @@ import hashlib import os import sys import struct -import tornado.web +import tornado from urllib.parse import urlparse import zlib @@ -1589,6 +1584,7 @@ def websocket_connect( ping_timeout: Optional[float] = None, max_message_size: int = _default_max_message_size, subprotocols: Optional[List[str]] = None, + resolver: Optional[Resolver] = None, ) -> "Awaitable[WebSocketClientConnection]": """Client-side websocket support. @@ -1632,6 +1628,9 @@ def websocket_connect( .. versionchanged:: 5.1 Added the ``subprotocols`` argument. + + .. versionchanged:: 6.3 + Added the ``resolver`` argument. """ if isinstance(url, httpclient.HTTPRequest): assert connect_timeout is None @@ -1653,6 +1652,7 @@ def websocket_connect( ping_timeout=ping_timeout, max_message_size=max_message_size, subprotocols=subprotocols, + resolver=resolver, ) if callback is not None: IOLoop.current().add_future(conn.connect_future, callback)