|
19 | 19 | import attr |
20 | 20 | from zope.interface import implementer |
21 | 21 |
|
22 | | -from twisted.internet.interfaces import IAddress |
| 22 | +from twisted.internet.interfaces import IAddress, IReactorTime |
23 | 23 | from twisted.python.failure import Failure |
| 24 | +from twisted.web.resource import IResource |
24 | 25 | from twisted.web.server import Request, Site |
25 | 26 |
|
26 | 27 | from synapse.config.server import ListenerConfig |
@@ -485,21 +486,39 @@ class _XForwardedForAddress: |
485 | 486 |
|
486 | 487 | class SynapseSite(Site): |
487 | 488 | """ |
488 | | - Subclass of a twisted http Site that does access logging with python's |
489 | | - standard logging |
| 489 | + Synapse-specific twisted http Site |
| 490 | +
|
| 491 | + This does two main things. |
| 492 | +
|
| 493 | + First, it replaces the requestFactory in use so that we build SynapseRequests |
| 494 | + instead of regular t.w.server.Requests. All of the constructor params are really |
| 495 | + just parameters for SynapseRequest. |
| 496 | +
|
| 497 | + Second, it inhibits the log() method called by Request.finish, since SynapseRequest |
| 498 | + does its own logging. |
490 | 499 | """ |
491 | 500 |
|
492 | 501 | def __init__( |
493 | 502 | self, |
494 | | - logger_name, |
495 | | - site_tag, |
| 503 | + logger_name: str, |
| 504 | + site_tag: str, |
496 | 505 | config: ListenerConfig, |
497 | | - resource, |
| 506 | + resource: IResource, |
498 | 507 | server_version_string, |
499 | | - *args, |
500 | | - **kwargs, |
| 508 | + reactor: IReactorTime, |
501 | 509 | ): |
502 | | - Site.__init__(self, resource, *args, **kwargs) |
| 510 | + """ |
| 511 | +
|
| 512 | + Args: |
| 513 | + logger_name: The name of the logger to use for access logs. |
| 514 | + site_tag: A tag to use for this site - mostly in access logs. |
| 515 | + config: Configuration for the HTTP listener corresponding to this site |
| 516 | + resource: The base of the resource tree to be used for serving requests on |
| 517 | + this site |
| 518 | + server_version_string: A string to present for the Server header |
| 519 | + reactor: reactor to be used to manage connection timeouts |
| 520 | + """ |
| 521 | + Site.__init__(self, resource, reactor=reactor) |
503 | 522 |
|
504 | 523 | self.site_tag = site_tag |
505 | 524 |
|
|
0 commit comments