Ben Darnell [Thu, 5 Jan 2012 08:27:45 +0000 (00:27 -0800)]
Handle redirects before processing data and sending it to streaming_callback.
Previously, if you were using follow_redirects and streaming_callback
and hit a redirect with a non-empty body, that body would be passed
to streaming_callback as well.
As a side effect, this improves compatibility with some misconfigured
sites that send Content-Encoding: gzip on redirects without actually
compressing the body.
Ben Darnell [Fri, 30 Dec 2011 20:54:36 +0000 (12:54 -0800)]
Improve websocket conformance as reported by autobahn.
Of note:
* It's now possible to send binary frames (auto-switched based on
whether the argument to write_message is bytes or unicode)
* Invalid utf8 in text frames is now an error
* Lots of fragmentation-related improvements
Ben Darnell [Wed, 7 Dec 2011 08:36:33 +0000 (00:36 -0800)]
A different approach to template stack traces:
Include the template source line as a comment in the generated code,
and add the magic necessary for python's normal stack traces to print
the (generated) source.
MinRK [Tue, 22 Nov 2011 23:48:46 +0000 (15:48 -0800)]
use '%s' formatting instead of '%d' for fds in IOLoop log messages
In case some poller implementations accept sockets or values other than
integer file descriptors, this prevents tornado's log messages from
raising errors.
Ben Darnell [Mon, 14 Nov 2011 04:15:44 +0000 (20:15 -0800)]
Thread safety for shared data structures (templates and static file hashes)
These data structures were basically safe before thanks to the GIL, but could
lead to wasted work in multithreaded environments (such as the new python2.7
app engine)
Also fixed a bug that made debug mode not invalidate static files.
David Koblas [Tue, 25 Oct 2011 22:24:41 +0000 (15:24 -0700)]
Use a AND instead of an OR to determine if the bits are set on the event
mask. Also, handle some basic error cases in the event bits and twisted
callback.
Ben Darnell [Tue, 4 Oct 2011 15:54:38 +0000 (08:54 -0700)]
Always advance _next_timeout in PeriodicCallback._schedule_next().
On fast machines (and platforms where time.time() has low resolution),
it's possible to make it through an IOLoop iteration with time.time()
unchanged, which would cause the callback to be run multiple times
regardless of the requested interval.
Ben Darnell [Tue, 4 Oct 2011 05:28:33 +0000 (22:28 -0700)]
Errors from socket.connect() should be treated the same way as async failures.
On freebsd non-blocking connect() may return certain errors (such as
ECONNREFUSED from localhost) immediately instead of returning EINPROGRESS
and then giving the error later.
Also improve the test for ipv6 compatibility, since freebsd returns a different
error than other platforms when ipv6 is not available.
Ben Darnell [Thu, 22 Sep 2011 17:38:35 +0000 (10:38 -0700)]
Fix a case in which chunked responses could be closed prematurely.
The bug manifests with certain patterns of fast-path/slow-path writes
on the IOStream, so it's difficult to test (it was more likely to occur in
2.0 than in 2.1).
Ben Darnell [Thu, 22 Sep 2011 07:10:43 +0000 (00:10 -0700)]
Fix connection-close detection for epoll.
Previously, closed connections with epoll sent an IOLoop.ERROR event
while there was still data in the OS's socket buffers. Event handlers
that did not drain the entire socket buffer before processing the
close event would lose data. (this was primarily an issue for
SimpleAsyncHTTPClient)
IOLoop.ERROR no longer includes EPOLLRDHUP (which is only supposed to be
used in edge-triggered mode: https://lkml.org/lkml/2003/7/12/132), so closed
connections while reading are signaled as zero-byte reads once the buffer
is drained (this was already the behavior of the select-based IOLoop).
Closed connections while writing are still signaled with EPOLLHUP.
Backwards-compatibility note: Listening for IOLoop.ERROR alone is no longer
sufficient for detecting closed connections on an otherwise unused socket.
IOLoop.ERROR must always be used in combination with READ or WRITE.
Print only the template trace of the bottommost UI module call, move testing.LogHandler to util.LogCaptureHandler, and rename testing.LogTestCase to testing.LogCaptureTestCase
Move `TCPServer` to `netutil`, change `handle_stream` callback to overridden method hook, move IP address hack for unix domain sockets to `HTTPConnection`