Commits on Jun 10, 2012
Commits on Jun 3, 2012
  1. Implement SPDY (v2) support

    alekstorm committed Jun 3, 2012
    This is incompatible with Tornado 2.x applications, but users should be able to update their code
    without too much trouble.
    Changes, in no particular order:
    * TLS NPN means that one of many protocols can be selected after a TCP connection is established. A
      layer of indirection was added to TCPServer to allow it to delegate handling of a TCP connection
      to whichever protocol handler was negotiated. If the `npn_protocols` parameter (a list of
      (name, handler) tuples in order of preference) was passed to the constructor, the connection is
      over TLS, and NPN succeeded, the handler for the chosen name will be called. Otherwise, the
      `protocol` constructor parameter will be called. For example, SPDYServer is essentially:
      class SPDYServer(TCPServer):
          def __init__(self, request_callback):
              http_protocol = HTTPServerProtocol(request_callback)
              TCPServer.__init__(self, http_protocol,
                      ('spdy/2', SPDYServerProtocol(request_callback)),
                      ('http/1.1', http_protocol)])
    * TCPServer was moved from netutil to its own module, tcpserver.
    * Since utilizing NPN support in Python 3.3 requires the `ssl.SSLContext` class, which isn't
      available in Python 2.x, the wrap_socket() top-level function was added to `netutil` to abstract
      away these details. In addition, the `SUPPORTS_NPN` constant was added as a convenience for
      determining if the system supported NPN.
    * Previously, TCP connection timeout, premature connection termination, and any HTTP parsing errors
      were handled in the client by executing the request callback with a fake 599 response. The user
      would then (if they remembered) call response.rethrow() to raise an exception. Separating the TCP
      connection from response handling made this scheme impossible (aside from being un-Pythonic in the
      first place). Instead, stack_context.wrap() was refactored to return a callable with a restore()
      method that returned a context manager that restores the saved stack context within its block.
      The above-mentioned errors are raised within this context. Top-level save() and switch_contexts()
      functions were also added, in case someone finds them useful. This is the primary incompatibility
      with current Tornado applications. `HTTPResponse.rethrow` has been removed, but the `error`
      attribute has been converted to a boolean representing whether the status code isn't 2xx or 3xx.
    * The SPDY standard is rapidly evolving. v3 has already been completed, and we're currently working
      on v4. To shield the user from this, the spdy* modules are actually directories that place their
      public interfaces in, and their version-specific implementation in This allows
      users to `import spdyserver`, and spdy* modules to `import spdyserver.v2`. Once v3 support is
      implemented, it will go in, and users won't notice the difference.
    * Much of the functionality of SimpleAsyncHTTPClient was factored out into QueuedAsyncHTTPClient,
      to allow SPDYClient to take advantage of its queuing logic as well. Subclasses pass a `handler`
      argument to the `initialize` pseudo-constructor, which gets called when a request is ready to be
      processed. If the handler determines that a new TCP connection is needed, it can call the
      `_http_connect` method to open one and return a (conn, address) pair.
    * Added push_callback, priority, force_connection, ssl_version attributes to httpclient.HTTPRequest.
    * Added framing, associated_urls, associated_to_url attributes to httpclient.HTTPResponse. The
      latter is necessary for notifying the client which URLs the server has promised to push, since
      pushed streams can be finished after the original response stream has.
    * Added framing, priority attributes to httpserver.HTTPRequest.
    * Since SPDY sessions are long-lived and streams are bidirectional, logic common to both clients and
      servers (stream management) has been factored out into the spdysession module. Each frame type,
      stream finishing events, and stream adding events all provide hooks for subclasses to override
      with client/server-specific functionality.
    * Previously, `web.RequestHandler` formatted the HTTP response itself and wrote it directly to the
      IOStream. To allow for SPDY framing, this responsibility has been moved to the
      HTTPRequest.connection object, which must provide the write_preamble() and write() methods - the
      former writes the response status line and headers, while the latter writes a chunk of the
      response body. In addition, the SPDYConnection object provides the push() method, which returns
      a new `SPDYConnection` that will push a resource to the client.
    * Body argument-parsing code (application/x-www-form-urlencoded or multipart/form data) needed by
      spdyserver, httpserver, and wsgi (and which was duplicated in the latter two) has been factored
      out into httputil.parse_body_arguments.
    * Although IOStream.connect() already takes a callback parameter, in SSLIOStream it's not called
      until the SSL handshake is completed (which contains TLS NPN) - and TCPServer, which doesn't call
      connect(), won't know which protocol handler to execute until that happens. To fix this, a
      set_connect_callback method was added to IOStream.
    * Since both SPDYSession and SimpleAsyncHTTPClient find a gzip decompressor useful, a
      GzipDecompressor class was added to the util module.
    * A new RequestHandler.push() method has been added that takes a relative URL as a parameter and
      opens a new push stream for it the next time flush() is called. A new HTTPRequest is constructed
      and passed to the RequestHandler's Application instance, just like normal - the only difference
      is that the response will be written to the pushed stream. Since SPDY forbids servers from
      pushing streams after any of the response body has been written to the network to avoid race
      conditions, calling this method after flush() has been called results in an exception.
    * The UIModule constructor now takes a `push_files` parameter that determines whether its
      Javascript and CSS files are automatically pushed when the UIModule is rendered. Also, the
      static_url() function provided to templates now takes an optional `push` parameter, which
      likewise causes the resulting URL to be pushed. Since the default for both of these parameters is
      easily overridden and users are aware that this patch introduces incompatibilities, I am
      confident enough to have both of these parameters default to `True`, but could be convinced
    * Gzip body encoding is automatically chosen if the `gzip` Application setting is `True` and the
      connection framing is SPDY, regardless of the request's Accept-Encoding header. SPDY specifically
      allows this.
    * The boolean `spdy` Application parameter was added to cause RequestHandler to add an
      "Alternate-Protocol: 443:npn-spdy" header to all responses if the connection framing is not
      already SPDY.
    * AsyncSSLTestCase has been added to the testing module as a base class for all tests that require
      SSL connections.
    * Since the websocket module has been updated to use the new HTTPConnection interface, it should,
      in theory, support SPDY framing. However, Chrome 19 crashes whenever I start it with
      --enable-websocket-over-spdy, so we'll need to work with the Chromium team to get this fixed.
      If there were unit tests for the websocket module, I would have updated them.
    * The spdyutil module, the bulk of which is in its v2 submodule, provides data structures
      representing SPDY frames (which can serialize themselves), as well as a non-blocking parse_frame
    * Mark Nottingham's `c_zlib` module has been borrowed (stolen) from his old nbhttp
      ( project, since the Python standard library's
      `zlib` module lacks pre-set dictionary support, which SPDY uses for header compression.
Commits on Jun 1, 2012
  1. Set version number to 2.3

    bdarnell committed Jun 1, 2012
  2. Final 2.3 release notes

    bdarnell committed Jun 1, 2012
Commits on May 31, 2012
  1. Merge pull request #521 from yoinc/master

    bdarnell committed May 31, 2012
    Restore context for all read methods
  2. Restore context for all read methods.

    eden committed May 31, 2012
    Prior to 2db0ace this was being done
    properly, but the refactor removed stack_context.wrap causing some issues
    in our upstream context managers.
Commits on May 28, 2012
  1. Set version number to 2.3rc1

    bdarnell committed May 28, 2012
  2. Doc updates

    bdarnell committed May 28, 2012
  3. Release note updates

    bdarnell committed May 28, 2012
  4. Remove unused variables

    bdarnell committed May 28, 2012
  5. Remove use of string exceptions in gen_test.

    bdarnell committed May 28, 2012
    These lines are not reached, but if they were they would fail with
    a less clear message than intended.
    Closes #520.
Commits on May 27, 2012
Commits on May 26, 2012
  1. Delay check for (and make it jython-friendly).

    bdarnell committed May 26, 2012
    Now HTTPConnection.address will always be the socket address,
    and the fake "" IP is only used in contexts that want an IP
    (i.e. HTTPRequest.remote_ip) but the connection is a non-IP socket.
  2. Merge pull request #514 from ahassany/fix-connectin-check

    bdarnell committed May 26, 2012
    Better connection check in RequestHandler
Commits on May 25, 2012
  1. Split large chunks of data in IOStream.write.

    ei-grad committed May 24, 2012
    Closes #515.
Commits on May 24, 2012
Commits on May 21, 2012
  1. Prevent leak of StackContexts in repeated gen.engine functions.

    bdarnell committed May 21, 2012
    Internally, StackContexts now return a deactivation callback,
    which can be used to prevent that StackContext from propagating
    further.  This is used in gen.engine because the decorator doesn't know
    which arguments are callbacks that need to be wrapped outside of its
    ExceptionStackContext.  This is deliberately undocumented for now.
    Closes #507.
  2. Release note updates

    bdarnell committed May 21, 2012
Commits on May 20, 2012
  1. Fix docstring formatting

    bdarnell committed May 20, 2012
  2. Merge remote-tracking branch 'jjwchoy/master'

    bdarnell committed May 20, 2012
    Modified linkify to accept a callable for extra_params.
    Closes #506.
  3. 304 responses no longer include entity headers like Content-Length

    bdarnell committed May 20, 2012
    This is required by the RFC as it may confuse caches.
  4. Add status_code to the OutputTransform.transform_first_chunk interface.

    bdarnell committed May 20, 2012
    This is needed for correct support of the 304 status code, which
    has no body and should not have either a Content-Length or
    Transfer-Encoding.  This is a backwards-incompatible change to an
    interface that was never technically private, but not included in the
    documentation and as far as I can tell was never used outside
    tornado itself.
Commits on May 19, 2012
  1. Fight bitrot in tornado.platform.twisted.

    bdarnell committed May 19, 2012
    A new release of zope.interface breaks things on python 2.5, and
    sets off our (overly-sensitive?) deprecation checking.
Commits on May 12, 2012
  1. Move to new module platform.common.

    bdarnell committed May 12, 2012
    Cleaned up the few windows-specific bits of code.  The socket-based
    Waker is also usable on Jython.