From: Ben Darnell Date: Sun, 27 Apr 2014 04:31:30 +0000 (-0400) Subject: Make HTTP1Connection and WSGIConnection subclasses of HTTPConnection. X-Git-Tag: v4.0.0b1~91^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42a00ef9ff391e4f6e8bef07d5a28c9a164ba5d2;p=thirdparty%2Ftornado.git Make HTTP1Connection and WSGIConnection subclasses of HTTPConnection. --- diff --git a/tornado/http1connection.py b/tornado/http1connection.py index 2e88f3642..fbe65ebf0 100644 --- a/tornado/http1connection.py +++ b/tornado/http1connection.py @@ -54,7 +54,7 @@ class HTTP1ConnectionParameters(object): self.body_timeout = body_timeout self.use_gzip = use_gzip -class HTTP1Connection(object): +class HTTP1Connection(httputil.HTTPConnection): """Implements the HTTP/1.x protocol. This class can be on its own for clients, or via `HTTP1ServerConnection` diff --git a/tornado/httputil.py b/tornado/httputil.py index 5e29906cc..23ef84b3e 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -542,8 +542,9 @@ class HTTPConnection(object): so that small responses can be written in the same call as their headers. :arg callback: a callback to be run when the write is complete. - :arg has_body: as an optimization, may be ``False`` to indicate - that no further writes will be coming. + :arg bool has_body: may be false to indicate that this message + has no body (and so does not need either a Content-Length + or Transfer-Encoding) Returns a `.Future` if no callback is given. """ diff --git a/tornado/wsgi.py b/tornado/wsgi.py index ad2d885ef..e5bc9f96b 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -84,7 +84,7 @@ class WSGIApplication(web.Application): return WSGIAdapter(self)(environ, start_response) -class _WSGIConnection(object): +class _WSGIConnection(httputil.HTTPConnection): def __init__(self, method, start_response, context): self.method = method self.start_response = start_response @@ -99,7 +99,8 @@ class _WSGIConnection(object): # so we can simply ignore the callback. pass - def write_headers(self, start_line, headers, chunk=None, callback=None): + def write_headers(self, start_line, headers, chunk=None, callback=None, + has_body=True): if self.method == 'HEAD': self._expected_content_remaining = 0 elif 'Content-Length' in headers: