From: Ben Darnell Date: Mon, 12 Jan 2015 03:22:16 +0000 (-0500) Subject: Make Application.start_request match HTTPServerConnectionDelegate.start_request. X-Git-Tag: v4.1.0b1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e5c6d7fec6871f5c5e87b433ec4c383b9f4ceb7;p=thirdparty%2Ftornado.git Make Application.start_request match HTTPServerConnectionDelegate.start_request. This was always intended, but unfortunately the change to HTTPServer is backwards-incompatible. --- diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 47c747263..e470e0e7d 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -114,6 +114,11 @@ class HTTPServer(TCPServer, httputil.HTTPServerConnectionDelegate): ``idle_connection_timeout``, ``body_timeout``, ``max_body_size`` arguments. Added support for `.HTTPServerConnectionDelegate` instances as ``request_callback``. + + .. versionchanged:: 4.1 + `.HTTPServerConnectionDelegate.start_request` is now called with + two arguments ``(server_conn, request_conn)`` (in accordance with the + documentation) instead of one ``(request_conn)``. """ def __init__(self, request_callback, no_keep_alive=False, io_loop=None, xheaders=False, ssl_options=None, protocol=None, @@ -153,7 +158,7 @@ class HTTPServer(TCPServer, httputil.HTTPServerConnectionDelegate): conn.start_serving(self) def start_request(self, server_conn, request_conn): - return _ServerRequestAdapter(self, request_conn) + return _ServerRequestAdapter(self, server_conn, request_conn) def on_close(self, server_conn): self._connections.remove(server_conn) @@ -226,13 +231,14 @@ class _ServerRequestAdapter(httputil.HTTPMessageDelegate): """Adapts the `HTTPMessageDelegate` interface to the interface expected by our clients. """ - def __init__(self, server, connection): + def __init__(self, server, server_conn, request_conn): self.server = server - self.connection = connection + self.connection = request_conn self.request = None if isinstance(server.request_callback, httputil.HTTPServerConnectionDelegate): - self.delegate = server.request_callback.start_request(connection) + self.delegate = server.request_callback.start_request( + server_conn, request_conn) self._chunks = None else: self.delegate = None diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 36365e0d7..1a7540c94 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -815,8 +815,8 @@ class StreamingChunkSizeTest(AsyncHTTPTestCase): def get_app(self): class App(HTTPServerConnectionDelegate): - def start_request(self, connection): - return StreamingChunkSizeTest.MessageDelegate(connection) + def start_request(self, server_conn, request_conn): + return StreamingChunkSizeTest.MessageDelegate(request_conn) return App() def fetch_chunk_sizes(self, **kwargs): diff --git a/tornado/web.py b/tornado/web.py index 038d424e8..3b77b418c 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1771,9 +1771,9 @@ class Application(httputil.HTTPServerConnectionDelegate): except TypeError: pass - def start_request(self, connection): + def start_request(self, server_conn, request_conn): # Modern HTTPServer interface - return _RequestDispatcher(self, connection) + return _RequestDispatcher(self, request_conn) def __call__(self, request): # Legacy HTTPServer interface