]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make Application.start_request match HTTPServerConnectionDelegate.start_request.
authorBen Darnell <ben@bendarnell.com>
Mon, 12 Jan 2015 03:22:16 +0000 (22:22 -0500)
committerBen Darnell <ben@bendarnell.com>
Mon, 12 Jan 2015 03:29:17 +0000 (22:29 -0500)
This was always intended, but unfortunately the change to HTTPServer
is backwards-incompatible.

tornado/httpserver.py
tornado/test/httpserver_test.py
tornado/web.py

index 47c7472636409ac6c6987879f38ca0754d670364..e470e0e7d153418a940ccb4526007374f783ae90 100644 (file)
@@ -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
index 36365e0d70437efecc0b48050c5b55bf1e3b70a3..1a7540c94be727275c9ced1bec086fa95f8318b3 100644 (file)
@@ -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):
index 038d424e8942cf51aae8f8bbef44f411455d6282..3b77b418c201f4d0f993140b9106621c35074a09 100644 (file)
@@ -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