now works on Python 3.
* Fixed a memory leak in `.AsyncHTTPClient` shutdown that affected
applications that created many HTTP clients and IOLoops.
+* New client request parameter ``decompress_response`` replaces
+ the existing ``use_gzip`` parameter; both names are accepted.
`tornado.httpserver`
~~~~~~~~~~~~~~~~~~~~
* HTTP implementation has been unified with ``tornado.simple_httpclient``
in `tornado.http1connection`.
* Now supports ``Transfer-Encoding: chunked`` for request bodies.
-* Now supports ``Content-Encoding: gzip`` for request bodies if ``gzip=True``
- is passed to the `.HTTPServer` constructor.
+* Now supports ``Content-Encoding: gzip`` for request bodies if
+ ``decompress_request=True`` is passed to the `.HTTPServer` constructor.
* The ``connection`` attribute of `.HTTPServerRequest` is now documented
for public use; applications are expected to write their responses
via the `.HTTPConnection` interface.
* `.RequestHandler.flush` now returns a `.Future` if no callback is given.
* ``HEAD`` requests in `.StaticFileHandler` no longer read the entire file.
* `.StaticFileHandler` now streams response bodies to the client.
+* New setting ``compress_response`` replaces the existing ``gzip``
+ setting; both names are accepted.
`tornado.websocket`
~~~~~~~~~~~~~~~~~~~
* ``default_handler_class`` and ``default_handler_args``:
This handler will be used if no other match is found;
use this to implement custom 404 pages (new in Tornado 3.2).
- * ``gzip``: If ``True``, responses in textual formats will be
- gzipped automatically.
+ * ``compress_response``: If ``True``, responses in textual formats
+ will be compressed automatically. New in Tornado 4.0.
+ * ``gzip``: Deprecated alias for ``compress_response`` since
+ Tornado 4.0.
* ``log_function``: This function will be called at the end
of every request to log the result (with one argument, the
`RequestHandler` object). The default implementation
curl.setopt(pycurl.USERAGENT, "Mozilla/5.0 (compatible; pycurl)")
if request.network_interface:
curl.setopt(pycurl.INTERFACE, request.network_interface)
- if request.use_gzip:
+ if request.decompress_response:
curl.setopt(pycurl.ENCODING, "gzip,deflate")
else:
curl.setopt(pycurl.ENCODING, "none")
"""
def __init__(self, no_keep_alive=False, chunk_size=None,
max_header_size=None, header_timeout=None, max_body_size=None,
- body_timeout=None, use_gzip=False):
+ body_timeout=None, decompress=False):
"""
:arg bool no_keep_alive: If true, always close the connection after
one request.
:arg float header_timeout: how long to wait for all headers (seconds)
:arg int max_body_size: maximum amount of data for body
:arg float body_timeout: how long to wait while reading body (seconds)
- :arg bool use_gzip: if true, decode incoming ``Content-Encoding: gzip``
+ :arg bool decompress: if true, decode incoming
+ ``Content-Encoding: gzip``
"""
self.no_keep_alive = no_keep_alive
self.chunk_size = chunk_size or 65536
self.header_timeout = header_timeout
self.max_body_size = max_body_size
self.body_timeout = body_timeout
- self.use_gzip = use_gzip
+ self.decompress = decompress
class HTTP1Connection(httputil.HTTPConnection):
Returns a `.Future` that resolves to None after the full response has
been read.
"""
- if self.params.use_gzip:
+ if self.params.decompress:
delegate = _GzipMessageDelegate(delegate, self.params.chunk_size)
return self._read_message(delegate)
request_timeout=20.0,
follow_redirects=True,
max_redirects=5,
- use_gzip=True,
+ decompress_response=True,
proxy_password='',
allow_nonstandard_methods=False,
validate_cert=True)
validate_cert=None, ca_certs=None,
allow_ipv6=None,
client_key=None, client_cert=None, body_producer=None,
- expect_100_continue=False):
+ expect_100_continue=False, decompress_response=None):
r"""All parameters except ``url`` are optional.
:arg string url: URL to fetch
or return the 3xx response?
:arg int max_redirects: Limit for ``follow_redirects``
:arg string user_agent: String to send as ``User-Agent`` header
- :arg bool use_gzip: Request gzip encoding from the server
+ :arg bool decompress_response: Request a compressed response from
+ the server and decompress it after downloading. Default is True.
+ New in Tornado 4.0.
+ :arg bool use_gzip: Deprecated alias for ``decompress_response``
+ since Tornado 4.0.
:arg string network_interface: Network interface to use for request.
``curl_httpclient`` only; see note below.
:arg callable streaming_callback: If set, ``streaming_callback`` will
before sending the request body. Only supported with
simple_httpclient.
-
.. note::
When using ``curl_httpclient`` certain options may be
self.follow_redirects = follow_redirects
self.max_redirects = max_redirects
self.user_agent = user_agent
- self.use_gzip = use_gzip
+ if decompress_response is not None:
+ self.decompress_response = decompress_response
+ else:
+ self.decompress_response = use_gzip
self.network_interface = network_interface
self.streaming_callback = streaming_callback
self.header_callback = header_callback
way other than `tornado.netutil.bind_sockets`.
.. versionchanged:: 4.0
- Added ``gzip``, ``chunk_size``, ``max_header_size``,
+ Added ``decompress_request``, ``chunk_size``, ``max_header_size``,
``idle_connection_timeout``, ``body_timeout``, ``max_body_size``
arguments. Added support for `.HTTPServerConnectionDelegate`
instances as ``request_callback``.
"""
def __init__(self, request_callback, no_keep_alive=False, io_loop=None,
- xheaders=False, ssl_options=None, protocol=None, gzip=False,
+ xheaders=False, ssl_options=None, protocol=None,
+ decompress_request=False,
chunk_size=None, max_header_size=None,
idle_connection_timeout=None, body_timeout=None,
max_body_size=None, max_buffer_size=None):
self.xheaders = xheaders
self.protocol = protocol
self.conn_params = HTTP1ConnectionParameters(
- use_gzip=gzip,
+ decompress=decompress_request,
chunk_size=chunk_size,
max_header_size=max_header_size,
header_timeout=idle_connection_timeout or 3600,
if (self.request.method == "POST" and
"Content-Type" not in self.request.headers):
self.request.headers["Content-Type"] = "application/x-www-form-urlencoded"
- if self.request.use_gzip:
+ if self.request.decompress_response:
self.request.headers["Accept-Encoding"] = "gzip"
req_path = ((self.parsed.path or '/') +
(('?' + self.parsed.query) if self.parsed.query else ''))
HTTP1ConnectionParameters(
no_keep_alive=True,
max_header_size=self.max_header_size,
- use_gzip=self.request.use_gzip),
+ decompress=self.request.decompress_response),
self._sockaddr)
start_line = httputil.RequestStartLine(self.request.method,
req_path, 'HTTP/1.1')
class GzipTest(GzipBaseTest, AsyncHTTPTestCase):
def get_httpserver_options(self):
- return dict(gzip=True)
+ return dict(decompress_request=True)
def test_gzip(self):
response = self.post_gzip('foo=bar')
return SimpleAsyncHTTPClient(io_loop=self.io_loop)
def get_httpserver_options(self):
- return dict(chunk_size=self.CHUNK_SIZE, gzip=True)
+ return dict(chunk_size=self.CHUNK_SIZE, decompress_request=True)
class MessageDelegate(HTTPMessageDelegate):
def __init__(self, connection):
**settings):
if transforms is None:
self.transforms = []
- if settings.get("gzip"):
+ if settings.get("compress_response") or settings.get("gzip"):
self.transforms.append(GZipContentEncoding)
else:
self.transforms = transforms