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.
Security fixes¶
tornado.simple_httpclientnow disables SSLv2 in all cases. Previously SSLv2 would be allowed if the Python interpreter was linked against a pre-1.0 version of OpenSSL.
Backwards-incompatible changes¶
tornado.process.fork_processesnow raisesSystemExitif all child processes exit cleanly rather than returningNone. The old behavior was surprising and inconsistent with most of the documented examples of this function (which did not check the return value).- On Python 2.6,
tornado.simple_httpclientonly supports SSLv3. This is because Python 2.6 does not expose a way to support both SSLv3 and TLSv1 without also supporting the insecure SSLv2. tornado.websocketno longer supports the older “draft 76” version of the websocket protocol by default, although this version can be enabled by overridingtornado.websocket.WebSocketHandler.allow_draft76.
tornado.httpclient¶
SimpleAsyncHTTPClientno longer hangs onHEADrequests, responses with no content, or emptyPOST/PUTresponse bodies.SimpleAsyncHTTPClientnow supports 303 and 307 redirect codes.tornado.curl_httpclientnow accepts non-integer timeouts.tornado.curl_httpclientnow supports basic authentication with an empty password.
tornado.httpserver¶
HTTPServerwithxheaders=Truewill no longer acceptX-Real-IPheaders that don’t look like valid IP addresses.HTTPServernow treats theConnectionrequest header as case-insensitive.
tornado.ioloop and tornado.iostream¶
IOStream.writenow works correctly when given an empty string.IOStream.read_until(andread_until_regex) now perform better when there is a lot of buffered data, which improves peformance ofSimpleAsyncHTTPClientwhen downloading files with lots of chunks.SSLIOStreamnow works correctly whenssl_versionis set to a value other thanSSLv23.- Idle
IOLoopsno longer wake up several times a second. tornado.ioloop.PeriodicCallbackno longer triggers duplicate callbacks when stopped and started repeatedly.
tornado.template¶
- Exceptions in template code will now show better stack traces that reference 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
Cookieheaders RequestHandler.redirectnow has astatusargument to send status codes other than 301 and 302.- New method
RequestHandler.on_finishmay be overridden for post-request processing (as a counterpart toRequestHandler.prepare) StaticFileHandlernow outputsContent-LengthandEtagheaders onHEADrequests.StaticFileHandlernow has overridableget_versionandparse_url_pathmethods for use in subclasses.RequestHandler.static_urlnow takes aninclude_hostparameter (in addition to the old support for theRequestHandler.include_hostattribute).
tornado.websocket¶
- Updated to support the latest version of the protocol, as finalized in RFC 6455.
- Many bugs were fixed in all supported protocol versions.
tornado.websocketno longer supports the older “draft 76” version of the websocket protocol by default, although this version can be enabled by overridingtornado.websocket.WebSocketHandler.allow_draft76.WebSocketHandler.write_messagenow accepts abinaryargument to send binary messages.- Subprotocols (i.e. the
Sec-WebSocket-Protocolheader) are now supported; see theWebSocketHandler.select_subprotocolmethod for details. .WebSocketHandler.get_websocket_schemecan be used to select the appropriate url scheme (ws://orwss://) in cases whereHTTPRequest.protocolis not set correctly.
Other modules¶
tornado.auth.TwitterMixin.authenticate_redirectnow takes acallback_uriparameter.tornado.auth.TwitterMixin.twitter_requestnow accepts both URLs and partial paths (complete URLs are useful for the search API which follows different patterns).- Exception handling in
tornado.genhas been improved. It is now possible to catch exceptions thrown by aTask. tornado.netutil.bind_socketsnow works whengetaddrinforeturns duplicate addresses.tornado.platform.twistedcompatibility has been significantly improved. Twisted version 11.1.0 is now supported in addition to 11.0.0.tornado.process.fork_processescorrectly reseeds therandommodule even whenos.urandomis not implemented.tornado.testing.mainsupports a new flag--exception_on_interrupt, which can be set to false to makeCtrl-Ckill the process more reliably (at the expense of stack traces when it does so).tornado.version_infois now a four-tuple so official releases can be distinguished from development branches.