企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
### Navigation - [index](# "General Index") - [modules](# "Python Module Index") | - [next](# "What鈥檚 new in Tornado 2.1.1") | - [previous](# "What鈥檚 new in Tornado 2.2.1") | - [Tornado 4.4.dev1 documentation](#) » - [Release notes](#) » # What's new in Tornado 2.2 ### Jan 30, 2012 ### Highlights - Updated and expanded WebSocket support. - Improved compatibility in the Twisted/Tornado bridge. - Template errors now generate better stack traces. - Better exception handling in [`tornado.gen`](# "tornado.gen"). ### Security fixes - `tornado.simple_httpclient` now disables SSLv2 in all cases. PreviouslySSLv2 would be allowed if the Python interpreter was linked against apre-1.0 version of OpenSSL. ### Backwards-incompatible changes - [`tornado.process.fork_processes`](# "tornado.process.fork_processes") now raises [`SystemExit`](https://docs.python.org/3.4/library/exceptions.html#SystemExit "(in Python v3.4)") [https://docs.python.org/3.4/library/exceptions.html#SystemExit] if all childprocesses exit cleanly rather than returning `None`. The old behaviorwas surprising and inconsistent with most of the documented examplesof this function (which did not check the return value). - On Python 2.6, `tornado.simple_httpclient` only supports SSLv3. Thisis because Python 2.6 does not expose a way to support both SSLv3 and TLSv1without also supporting the insecure SSLv2. - [`tornado.websocket`](# "tornado.websocket") no longer supports the older “draft 76” versionof the websocket protocol by default, although this version canbe enabled by overriding `tornado.websocket.WebSocketHandler.allow_draft76`. ### `tornado.httpclient` - `SimpleAsyncHTTPClient` no longer hangs on `HEAD` requests,responses with no content, or empty `POST`/`PUT` response bodies. - `SimpleAsyncHTTPClient` now supports 303 and 307 redirect codes. - `tornado.curl_httpclient` now accepts non-integer timeouts. - `tornado.curl_httpclient` now supports basic authentication with anempty password. ### `tornado.httpserver` - [`HTTPServer`](# "tornado.httpserver.HTTPServer") with `xheaders=True` will no longer accept`X-Real-IP` headers that don't look like valid IP addresses. - [`HTTPServer`](# "tornado.httpserver.HTTPServer") now treats the `Connection` request header ascase-insensitive. ### `tornado.ioloop` and `tornado.iostream` - `IOStream.write` now works correctly when given an empty string. - `IOStream.read_until` (and `read_until_regex`) now perform betterwhen there is a lot of buffered data, which improves peformance of`SimpleAsyncHTTPClient` when downloading files with lots ofchunks. - [`SSLIOStream`](# "tornado.iostream.SSLIOStream") now works correctly when `ssl_version` is set toa value other than `SSLv23`. - Idle `IOLoops` no longer wake up several times a second. - [`tornado.ioloop.PeriodicCallback`](# "tornado.ioloop.PeriodicCallback") no longer triggers duplicate callbackswhen stopped and started repeatedly. ### `tornado.template` - Exceptions in template code will now show better stack traces thatreference lines from the original template file. - `{#` and `#}` can now be used for comments (and unlike the old`{% comment %}` directive, these can wrap other template directives). - Template directives may now span multiple lines. ### `tornado.web` - Now behaves better when given malformed `Cookie` headers - [`RequestHandler.redirect`](# "tornado.web.RequestHandler.redirect") now has a `status` argument to sendstatus codes other than 301 and 302. - New method [`RequestHandler.on_finish`](# "tornado.web.RequestHandler.on_finish") may be overridden for post-requestprocessing (as a counterpart to [`RequestHandler.prepare`](# "tornado.web.RequestHandler.prepare")) - [`StaticFileHandler`](# "tornado.web.StaticFileHandler") now outputs `Content-Length` and `Etag` headerson `HEAD` requests. - [`StaticFileHandler`](# "tornado.web.StaticFileHandler") now has overridable `get_version` and`parse_url_path` methods for use in subclasses. - [`RequestHandler.static_url`](# "tornado.web.RequestHandler.static_url") now takes an `include_host` parameter(in addition to the old support for the `RequestHandler.include_host`attribute). ### `tornado.websocket` - Updated to support the latest version of the protocol, as finalizedin RFC 6455. - Many bugs were fixed in all supported protocol versions. - [`tornado.websocket`](# "tornado.websocket") no longer supports the older “draft 76” versionof the websocket protocol by default, although this version canbe enabled by overriding `tornado.websocket.WebSocketHandler.allow_draft76`. - [`WebSocketHandler.write_message`](# "tornado.websocket.WebSocketHandler.write_message") now accepts a `binary` argumentto send binary messages. - Subprotocols (i.e. the `Sec-WebSocket-Protocol` header) are now supported;see the [`WebSocketHandler.select_subprotocol`](# "tornado.websocket.WebSocketHandler.select_subprotocol") method for details. - `.WebSocketHandler.get_websocket_scheme` can be used to select theappropriate url scheme (`ws://` or `wss://`) in cases where`HTTPRequest.protocol` is not set correctly. ### Other modules - [`tornado.auth.TwitterMixin.authenticate_redirect`](# "tornado.auth.TwitterMixin.authenticate_redirect") now takes a`callback_uri` parameter. - [`tornado.auth.TwitterMixin.twitter_request`](# "tornado.auth.TwitterMixin.twitter_request") now accepts both URLs andpartial paths (complete URLs are useful for the search API which followsdifferent patterns). - Exception handling in [`tornado.gen`](# "tornado.gen") has been improved. It is now possibleto catch exceptions thrown by a `Task`. - [`tornado.netutil.bind_sockets`](# "tornado.netutil.bind_sockets") now works when `getaddrinfo` returnsduplicate addresses. - [`tornado.platform.twisted`](# "tornado.platform.twisted") compatibility has been significantly improved.Twisted version 11.1.0 is now supported in addition to 11.0.0. - [`tornado.process.fork_processes`](# "tornado.process.fork_processes") correctly reseeds the [`random`](https://docs.python.org/3.4/library/random.html#module-random "(in Python v3.4)") [https://docs.python.org/3.4/library/random.html#module-random] moduleeven when [`os.urandom`](https://docs.python.org/3.4/library/os.html#os.urandom "(in Python v3.4)") [https://docs.python.org/3.4/library/os.html#os.urandom] is not implemented. - [`tornado.testing.main`](# "tornado.testing.main") supports a new flag `--exception_on_interrupt`,which can be set to false to make `Ctrl-C` kill the process morereliably (at the expense of stack traces when it does so). - `tornado.version_info` is now a four-tuple so official releases can bedistinguished from development branches. © Copyright 2009-2016, The Tornado Authors. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.