Ben Darnell [Sat, 26 Apr 2014 18:26:41 +0000 (14:26 -0400)]
Add on_close to HTTPServerConnectionDelegate.
Add close_all_connections method to HTTPServer for testing cleanup.
On Python versions before 3.4, the GC has problems with generators,
so the previous approach of closing all the file descriptors and
leave the rest to the GC no longer works. (Only Python 3.3 prints
the uncollectable garbage warnings, but the problem is present
in earlier versions).
Ben Darnell [Mon, 21 Apr 2014 04:26:40 +0000 (00:26 -0400)]
Help out the CPython GC by clearing some references in IOLoop.close.
This prevents some of the ResourceWarnings from the test suite on python
3.3 (older versions didn't report the leaks; newer versions are better
at freeing generators). Since this is in IOLoop.close, it mainly
affects tests.
Ben Darnell [Sun, 20 Apr 2014 21:01:43 +0000 (17:01 -0400)]
Move address manipulation from HTTP1Connection to HTTPServer.
The connection now contains only an opaque 'origin' object to which
the caller can attach address info. This object can also be mutated
as in HTTPServer's xheader support.
Ben Darnell [Sun, 20 Apr 2014 00:13:40 +0000 (20:13 -0400)]
Timeout micro-optimizations.
Use the (C) timedelta.total_seconds function when available. But it's
still a bit faster to use numeric timeouts instead of back-and-forth
through timedelta, so do that instead in http1connection.
Ben Darnell [Sat, 19 Apr 2014 02:16:55 +0000 (22:16 -0400)]
Read less aggressively in IOStream.
Previously, we would drain the socket buffer into the IOStream read buffer
before trying to satisfy application requests. This would result in
unnecessary memory use, and on a fast network reads could fail because the
buffer would fill up. Now we stop reading when we can satisfy the current
request (at least for read_bytes and read_until with max_bytes; unbounded
read_until still reads aggressively).
This commit includes a change to IOStream close_callback semantics. Since
the only way to reliably detect a closed connection (across all IOLoop
implementations) is to read past the end of the stream, the IOStream will
not detect a closed connection while there is some buffered data that could
satisfy a future read.
Ben Darnell [Sat, 29 Mar 2014 15:01:14 +0000 (15:01 +0000)]
Add body_producer argument to httpclient.HTTPRequest.
This allows for sending non-contiguous or asynchronously-produced
request bodies, including chunked encoding when the content-length
is not known in advance.
Ben Darnell [Sat, 29 Mar 2014 14:03:15 +0000 (14:03 +0000)]
Add option to disable the Resolver tests with an environment variable.
The resolver tests depend on external network resources; the twisted
resolver will time out when the network is unvailable instead of
returning an immediate failure like the other implementations.
Ben Darnell [Sun, 16 Mar 2014 16:57:54 +0000 (12:57 -0400)]
Make Application an HTTPServerConnectionDelegate.
HTTPServer now forwards delegate events to its request callback
if it implements this interface. This allows the application to be
in the loop as the request is being read.
Ben Darnell [Sat, 15 Mar 2014 04:45:09 +0000 (00:45 -0400)]
Refactor unittest/unittest2 imports to fix issues with unittest2 on py3.
Never use unittest2 on python 3 (it appears to not interoperate with
the standard unittest module). On python 2, use the same logic in
tornado.testing and tornado.test.util to select an implementation.
Ben Darnell [Thu, 13 Mar 2014 14:15:41 +0000 (10:15 -0400)]
Improve simple_httpclient ssl configuration to pass howsmyssl.com.
Remove insecure cipher suites and disable TLS compression. The option
to disable compression was only added in Python 3.3 so we do not
pass the test on older versions, but we come as close as possible with
the APIs available.
Doug Goldstein [Fri, 28 Feb 2014 14:48:26 +0000 (08:48 -0600)]
define and use errno_from_exception abstraction
If an OSError or IOError are instantiated without an errno value, e.g.
e = OSError(). The existing code would give an IndexError: tuple index
out of range. However there have been cases that the errno attribute
wasn't populated so instead of switching to it this introduces a helper
function to ensure we get the errno value through whatever means
possible.
Ben Darnell [Wed, 19 Feb 2014 04:15:19 +0000 (23:15 -0500)]
Document the fact that tornado.options configures logging by default.
Add tests and comments for how to disable this configuration.
Make it slightly easier to disable by making the command line
flag case-insensitive and allowing `None` instead of the string "none"
when setting the flag in code.