/opt/cloudlinux/venv/lib/python3.11/site-packages/aiohttp
"""Low level HTTP server.""" import asyncio from typing import Any, Awaitable, Callable, Dict, List, Optional # noqa from .abc import AbstractStreamWriter from .helpers import get_running_loop from .http_parser import RawRequestMessage from .streams import StreamReader from .web_protocol import RequestHandler, _RequestFactory, _RequestHandler from .web_request import BaseRequest __all__ = ("Server",) class Server: def __init__( self, handler: _RequestHandler, *, request_factory: Optional[_RequestFactory] = None, handler_cancellation: bool = False, loop: Optional[asyncio.AbstractEventLoop] = None, **kwargs: Any ) -> None: self._loop = get_running_loop(loop) self._connections: Dict[RequestHandler, asyncio.Transport] = {} self._kwargs = kwargs self.requests_count = 0 self.request_handler = handler self.request_factory = request_factory or self._make_request self.handler_cancellation = handler_cancellation @property def connections(self) -> List[RequestHandler]: return list(self._connections.keys()) def connection_made( self, handler: RequestHandler, transport: asyncio.Transport ) -> None: self._connections[handler] = transport def connection_lost( self, handler: RequestHandler, exc: Optional[BaseException] = None ) -> None: if handler in self._connections: del self._connections[handler] def _make_request( self, message: RawRequestMessage, payload: StreamReader, protocol: RequestHandler, writer: AbstractStreamWriter, task: "asyncio.Task[None]", ) -> BaseRequest: return BaseRequest(message, payload, protocol, writer, task, self._loop) def pre_shutdown(self) -> None: for conn in self._connections: conn.close() async def shutdown(self, timeout: Optional[float] = None) -> None: coros = (conn.shutdown(timeout) for conn in self._connections) await asyncio.gather(*coros) self._connections.clear() def __call__(self) -> RequestHandler: try: return RequestHandler(self, loop=self._loop, **self._kwargs) except TypeError: # Failsafe creation: remove all custom handler_args kwargs = { k: v for k, v in self._kwargs.items() if k in ["debug", "access_log_class"] } return RequestHandler(self, loop=self._loop, **kwargs)
.
Edit
..
Edit
.hash
Edit
__init__.py
Edit
__pycache__
Edit
_cparser.pxd
Edit
_find_header.pxd
Edit
_headers.pxi
Edit
_helpers.cpython-311-x86_64-linux-gnu.so
Edit
_helpers.pyi
Edit
_helpers.pyx
Edit
_http_parser.cpython-311-x86_64-linux-gnu.so
Edit
_http_parser.pyx
Edit
_http_writer.cpython-311-x86_64-linux-gnu.so
Edit
_http_writer.pyx
Edit
_websocket.cpython-311-x86_64-linux-gnu.so
Edit
_websocket.pyx
Edit
abc.py
Edit
base_protocol.py
Edit
client.py
Edit
client_exceptions.py
Edit
client_proto.py
Edit
client_reqrep.py
Edit
client_ws.py
Edit
compression_utils.py
Edit
connector.py
Edit
cookiejar.py
Edit
formdata.py
Edit
hdrs.py
Edit
helpers.py
Edit
http.py
Edit
http_exceptions.py
Edit
http_parser.py
Edit
http_websocket.py
Edit
http_writer.py
Edit
locks.py
Edit
log.py
Edit
multipart.py
Edit
payload.py
Edit
payload_streamer.py
Edit
py.typed
Edit
pytest_plugin.py
Edit
resolver.py
Edit
streams.py
Edit
tcp_helpers.py
Edit
test_utils.py
Edit
tracing.py
Edit
typedefs.py
Edit
web.py
Edit
web_app.py
Edit
web_exceptions.py
Edit
web_fileresponse.py
Edit
web_log.py
Edit
web_middlewares.py
Edit
web_protocol.py
Edit
web_request.py
Edit
web_response.py
Edit
web_routedef.py
Edit
web_runner.py
Edit
web_server.py
Edit
web_urldispatcher.py
Edit
web_ws.py
Edit
worker.py
Edit