Source code for harp.http.typing.bridges

from typing import AsyncIterator, Protocol

from multidict import CIMultiDict, MultiDict


[docs] class HttpRequestBridge(Protocol): """ The HttpRequestBridge protocol defines the methods required by the HttpRequest object for it to attach to a real implementation, such as WSGI, ASGI, ... """
[docs] def get_server_ipaddr(self) -> str: ...
[docs] def get_server_port(self) -> int: ...
[docs] def get_method(self) -> str: ...
[docs] def get_path(self) -> str: ...
[docs] def get_query(self) -> MultiDict: ...
[docs] def get_headers(self) -> CIMultiDict: ...
[docs] async def read(self) -> bytes: ...
[docs] async def stream(self) -> AsyncIterator[bytes]: yield ...
[docs] class HttpResponseBridge(Protocol): """ The HttpResponseBridge protocol defines the necessary methods to actually send an HttpResponse through a real channel. """