summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2021-04-23 17:06:47 +0100
committerGitHub <noreply@github.com>2021-04-23 17:06:47 +0100
commit59d24c5bef4e05fa7be0cad1f7e63f0a0097374b (patch)
tree73d1af65fe53576035380929b3ee4b6836317ec9 /synapse/http
parentAdd type hints to auth and auth_blocking. (#9876) (diff)
downloadsynapse-59d24c5bef4e05fa7be0cad1f7e63f0a0097374b.tar.xz
pass a reactor into SynapseSite (#9874)
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/site.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/synapse/http/site.py b/synapse/http/site.py
index 32b5e19c09..e911ee4809 100644
--- a/synapse/http/site.py
+++ b/synapse/http/site.py
@@ -19,8 +19,9 @@ from typing import Optional, Tuple, Type, Union
 import attr
 from zope.interface import implementer
 
-from twisted.internet.interfaces import IAddress
+from twisted.internet.interfaces import IAddress, IReactorTime
 from twisted.python.failure import Failure
+from twisted.web.resource import IResource
 from twisted.web.server import Request, Site
 
 from synapse.config.server import ListenerConfig
@@ -485,21 +486,39 @@ class _XForwardedForAddress:
 
 class SynapseSite(Site):
     """
-    Subclass of a twisted http Site that does access logging with python's
-    standard logging
+    Synapse-specific twisted http Site
+
+    This does two main things.
+
+    First, it replaces the requestFactory in use so that we build SynapseRequests
+    instead of regular t.w.server.Requests. All of the  constructor params are really
+    just parameters for SynapseRequest.
+
+    Second, it inhibits the log() method called by Request.finish, since SynapseRequest
+    does its own logging.
     """
 
     def __init__(
         self,
-        logger_name,
-        site_tag,
+        logger_name: str,
+        site_tag: str,
         config: ListenerConfig,
-        resource,
+        resource: IResource,
         server_version_string,
-        *args,
-        **kwargs,
+        reactor: IReactorTime,
     ):
-        Site.__init__(self, resource, *args, **kwargs)
+        """
+
+        Args:
+            logger_name:  The name of the logger to use for access logs.
+            site_tag:  A tag to use for this site - mostly in access logs.
+            config:  Configuration for the HTTP listener corresponding to this site
+            resource:  The base of the resource tree to be used for serving requests on
+                this site
+            server_version_string: A string to present for the Server header
+            reactor: reactor to be used to manage connection timeouts
+        """
+        Site.__init__(self, resource, reactor=reactor)
 
         self.site_tag = site_tag