Ben Darnell [Wed, 14 Jul 2010 23:31:22 +0000 (16:31 -0700)]
Better timeout handling in AsyncHTTPClient2. Tornado and libcurl may
use different clock functions, which can cause timeouts to be delayed
(in some cases until the next fetch is started). This change
resynchronizes the schedule after each timeout call.
Ben Darnell [Sat, 10 Jul 2010 01:15:12 +0000 (18:15 -0700)]
In AsyncHTTPClient2, disable IPv6 for versions of libcurl with the
socket-reopening bug (i.e. <= 7.21.0). (this can be overridden if needed
with a prepare_curl_callback)
Ben Darnell [Fri, 9 Jul 2010 20:07:43 +0000 (13:07 -0700)]
Unquote percent escapes in captured groups in the path component of the URI,
to be more consistent with our handling of query parameters.
This change is slightly backwards-incompatible: applications that have
already added an unquote() call on arguments to RequestHandler.get/post
will need to remove them.
URI spec requires that '/' and '%2F' be distinguishable, so it's incorrect
to escape at this level. The next commit will instead unquote captured
groups before passing them to get()/post() in web.py
Ben Darnell [Fri, 9 Jul 2010 01:27:43 +0000 (18:27 -0700)]
Parse percent escapes in the path component of the uri, to be more
consistent with our handling of query parameters (especially important
when capturing groups are used in the URLSpec regex).
This change is slightly backwards-incompatible: applications that have
already added an unquote() call on arguments to RequestHandler.get/post
or use percent escapes in URLSpec patterns will need to remove them.
Ben Darnell [Sat, 26 Jun 2010 23:00:26 +0000 (16:00 -0700)]
Update the set of active file descriptors immediately after calling perform
instead of after running user callbacks, since those callbacks might have
started using file descriptors that were closed by curl in perform().
Ben Darnell [Fri, 18 Jun 2010 22:59:19 +0000 (15:59 -0700)]
Close wsgi responses correctly - the close method, if present, will
be on the result of self.wsgi_application() and not on the list
of output we're building up.
Ben Darnell [Thu, 10 Jun 2010 21:49:57 +0000 (14:49 -0700)]
In the libcurl file descriptor limit hack, log to both stderr and
logging.error since they may got to different places and one may be
more visible than the other.
Ben Darnell [Mon, 31 May 2010 06:04:10 +0000 (23:04 -0700)]
Optionally allow nonstandard http methods to be used in httpclient.
By default we check that the method is one of the standard ones (and
is capitalized correctly), but this can be overridden to work with a
server that has implemented nonstandard methods (e.g. CouchDB)
Ben Darnell [Mon, 31 May 2010 05:50:11 +0000 (22:50 -0700)]
Clear the close_callback set on the IOStream by RequestHandlers in
finish(), so that the close_callback does not prevent garbage collection
of the handlers.
Ben Darnell [Mon, 31 May 2010 05:16:11 +0000 (22:16 -0700)]
Improve parsing of multipart/form-data headers.
This change was motivated by google app engine's xmpp support,
which uses different spacing in the header than other common clients
and quotes its boundary string.
The one-shot behavior of receive_message was intentional, and simply
requeuing the old callback every time will eventually overflow the
stack due to repeated async_callback wrappers. An alternate interface
that doesn't require receive_message to be called for every message
may be added in a future change.
Ben Darnell [Mon, 17 May 2010 02:33:59 +0000 (19:33 -0700)]
Use a lambda instead of functools.partial for pycurl.HEADERFUNCTION.
Older versions of pycurl (including 7.16.2.1, which is the recommended
version for Mac OS X 10.5) only work with real functions, not objects
with a __call__ method like functools.partial.
Remove exception-swallowing - curl versions that predate HEADERFUNCTION
are no longer supported.
Ben Darnell [Wed, 21 Apr 2010 20:57:05 +0000 (13:57 -0700)]
cStringIO's constructor uses a 16-bit encoding when given a unicode
string. This is inconsistent with its write method, which encodes all
strings as ascii (and rejects unicode strings iff they have any
non-ascii characters). This change uses utf-8 as the default encoding
when constructing cStringIO objects in tornado.
Ben Darnell [Tue, 20 Apr 2010 22:40:33 +0000 (15:40 -0700)]
Send all logging to the root logger instead of per-module loggers.
This undoes the effect of
http://github.com/facebook/tornado/commit/e391fd289ed085671344504cc5b1fa84f5a3c774
Per-module loggers are problematic because only the top-level convenience
logging.{error,warning,...} functions configure logging on-demand, so
an app that only uses per-module loggers will produce no output except
"no handlers found for logger X". Since tornado.ioloop swallows and logs
all exceptions, this makes it too hard to tell what's going on for apps
that do not configure logging explicitly.
Instead of setting log levels on individual module's loggers,
logging.Handler.addFilter can be used with a filter that examines
the module attribute of the log record.
Ben Darnell [Mon, 19 Apr 2010 18:20:03 +0000 (11:20 -0700)]
Better HTTP header parsing: Allow (and strip) any amount of leading
and trailing whitespace around header values instead of just a single
space. Such whitespace is legal but appears to be uncommon (and nginx
apparently normalizes everything to a single space)
http://tools.ietf.org/html/rfc2616#page-31
Ben Darnell [Mon, 5 Apr 2010 19:23:24 +0000 (12:23 -0700)]
Make options.__getattr__ raise AttributeError instead of Error for consistency
with standard attribute lookups (so getattr(options, 'foo', None) works
if no option 'foo' has been defined).
Ben Darnell [Fri, 26 Mar 2010 22:55:04 +0000 (15:55 -0700)]
Make add_handlers (for multiple hostnames) usable with static_path (which
forces the creation of a wildcard handler) by maintaining a sensible order
for handler groups.
Dolapo Falola [Thu, 18 Mar 2010 01:44:16 +0000 (18:44 -0700)]
add a template_loader application setting for using custom template loaders. a slight refactoring of TemplateLoader's load method to expose some internals. also, add a reset method to the loader that's called in debug mode to flush the template cache.
Ben Darnell [Tue, 9 Mar 2010 17:17:23 +0000 (09:17 -0800)]
Fix bug with IOLoop's 'waker' pipe which rendered it ineffective on linux
and mac (where pipes are unidirectional) and caused high cpu usage
on solaris (where pipes are bidirectional). Thanks to Jari Ahonen for
finding the bug.
Ben Darnell [Thu, 4 Mar 2010 20:30:26 +0000 (12:30 -0800)]
Set the close-on-exec flag on file descriptors used by IOLoop (epoll/kqueue
and pipe) so that long-lived autoreloading processes don't leak file
descriptors.
Ben Darnell [Thu, 4 Mar 2010 19:52:18 +0000 (11:52 -0800)]
Use a WeakKeyDictionary instead of a regular dictionary to associate
IOLoop and AsyncHTTPClients. This prevents leaks of memory and file
descriptors when one process (in my case a unit test runner) create
many IOLoop/AsyncHTTPClient pairs.
Ben Darnell [Tue, 2 Mar 2010 02:55:38 +0000 (18:55 -0800)]
Revamp logging configuration.
* If --logging=none, tornado will not touch the python logging config.
* Colored output is optional. If curses is not available or stderr is not
a tty, non-colorized output will be used.
* Log output to stderr can be suppressed with --log_to_stderr=false
* Logs can be written to a file (non-colorized) with --log_file_prefix.
Logs will be rotated, which can be controlled with --log_file_max_size
and --log_file_num_backups.
* By default, logs go to a file if --log_file_prefix is set and to stderr
if it is not. To log to both stderr and a file, --log_to_stderr must
be set to true explicitly.
Bret Taylor [Fri, 5 Feb 2010 18:24:57 +0000 (10:24 -0800)]
Support passing in cookie value directly in cases where you have to parse the value from other sources (e.g., from the URL for Flash requests). Also fix documentation error for Facebook Connect.
Ben Darnell [Thu, 4 Feb 2010 21:18:43 +0000 (13:18 -0800)]
Don't set content-length in StaticFileHandler unless we're actually
sending the content. Some browsers get confused by this (e.g. the
version of webkit embedded in fluid, but not the version used in chrome).