class HTTPFactory(protocol.ServerFactory): (source)
Known subclasses: twisted.web.server.Site
Constructor: HTTPFactory(logPath, timeout, logFormatter, reactor)
Factory for HTTP server.
Method | __init__ |
No summary |
Method | build |
Create an instance of a subclass of Protocol. |
Method | log |
Write a line representing request to the access log file. |
Method | start |
Set up request logging if necessary. |
Method | stop |
This will be called before I stop listening on all Ports/Connectors. |
Class Variable | log |
A file (object with write(data: str) and close() methods) that will be used for logging HTTP requests and responses in the standard Combined Log Format . |
Instance Variable | log |
Undocumented |
Instance Variable | reactor |
An IReactorTime provider used to manage connection timeouts and compute logging timestamps. |
Instance Variable | time |
Undocumented |
Method | _get_log |
Undocumented |
Method | _get_log |
Undocumented |
Method | _open |
Override in subclasses, e.g. to use twisted.python.logfile . |
Method | _update |
Update log datetime periodically, so we aren't always recalculating it. |
Instance Variable | _log |
A cached datetime string for log messages, updated by _logDateTimeCall. |
Instance Variable | _log |
A delayed call for the next update to the cached log datetime string. |
Instance Variable | _log |
Undocumented |
Instance Variable | _log |
See the logFormatter parameter to __init__ |
Instance Variable | _nativeize |
A flag that indicates whether the log file being written to wants native strings (True) or bytes (False). This is only to support writing to twisted.python.log which, unfortunately, works with native strings. |
Inherited from Factory
(via ServerFactory
):
Class Method | for |
Create a factory for the given protocol. |
Method | do |
Make sure startFactory is called. |
Method | do |
Make sure stopFactory is called. |
Method | log |
Describe this factory for log messages. |
Class Variable | noisy |
Undocumented |
Class Variable | protocol |
Undocumented |
Instance Variable | num |
Undocumented |
str | bytes | None
= None, timeout: int | float
= _REQUEST_TIMEOUT, logFormatter: IAccessLogFormatter | None
= None, reactor: IReactorTime | None
= None):
(source)
¶
twisted.web.server.Site
Parameters | |
logstr or bytes | File path to which access log messages will be written or None to disable logging. |
timeout:float | The initial value of timeOut , which defines the idle connection timeout in seconds, or None to disable the idle timeout. |
logIAccessLogFormatter provider | An object to format requests into log lines for the access log. combinedLogFormatter when None is passed. |
reactor:IReactorTime | None | An IReactorTime provider used to manage connection timeouts and compute logging timestamps. Defaults to the global reactor. |
twisted.web.server.Site
Create an instance of a subclass of Protocol.
The returned instance will handle input on an incoming server connection, and an attribute "factory" pointing to the creating factory.
Alternatively, None
may be returned to immediately close the new connection.
Override this method to alter how Protocol instances get created.
Parameters | |
addr:IAddress | an object implementing IAddress |
Returns | |
Protocol | None | Undocumented |
Write a line representing request to the access log file.
Parameters | |
request:Request | The request object about which to log. |
This will be called before I stop listening on all Ports/Connectors.
This can be overridden to perform 'shutdown' tasks such as disconnecting database connections, closing files, etc.
It will be called, for example, before an application shuts down, if it was connected to a port. User code should not call this function directly.
A file (object with write(data: str) and close() methods) that will be used for logging HTTP requests and responses in the standard Combined Log Format .
Note | |
for backwards compatibility purposes, this may be set to an object with a write(data: bytes) method, but these will be detected (by checking if it's an instance of BufferedIOBase ) and replaced with a TextIOWrapper when retrieved by getting the attribute again. |
def _get_logFile(self, newLogFile:
BufferedIOBase | _MinimalLogFile
):
(source)
¶
Undocumented
A flag that indicates whether the log file being written to wants native strings (True) or bytes (False). This is only to support writing to twisted.python.log
which, unfortunately, works with native strings.