The HttpPlatform service: make builds it, and
HttpPlatformService(platform, compression, file_response, file_web_response) makes one of functions (a test double, say).
Attributes#
| Attribute | Type | Description |
|---|---|---|
platform | PlatformName = platform | |
compression | Compression = compression |
Functions#
__init__#
__init__(platform, compression, file_response, file_web_response) -> None| Parameter | Type | Description |
|---|---|---|
platform | PlatformName | |
compression | Compression | |
file_response | Callable[..., Effect[HttpServerResponse, PlatformError]] | |
file_web_response | Callable[..., Effect[HttpServerResponse]] |
def __init__(
self,
platform: PlatformName,
compression: Compression,
file_response: Callable[..., Effect[HttpServerResponse, PlatformError]],
file_web_response: Callable[..., Effect[HttpServerResponse]],
) -> None:
self.platform = platform
self.compression = compression
self._file_response = file_response
self._file_web_response = file_web_responsefile_response#
file_response(path, **options) -> Effect[HttpServerResponse, PlatformError]A response streaming the file at path, with an etag
and a last-modified header from its stat. offset and
bytes_to_read pick a range (clamped to the file); status,
status_text, headers and content_type go on the
response. Fails with a PlatformError when the file cannot be
stat'ed, or offset or bytes_to_read is invalid.
| Parameter | Type | Description |
|---|---|---|
path | str | |
options | Unpack[FileOptions] = {} |
Returns Effect[HttpServerResponse, PlatformError]
def file_response(
self, path: str, **options: Unpack[FileOptions]
) -> Effect[HttpServerResponse, PlatformError]:
"""A response streaming the file at ``path``, with an ``etag``
and a ``last-modified`` header from its ``stat``. ``offset`` and
``bytes_to_read`` pick a range (clamped to the file); ``status``,
``status_text``, ``headers`` and ``content_type`` go on the
response. Fails with a ``PlatformError`` when the file cannot be
stat'ed, or ``offset`` or ``bytes_to_read`` is invalid."""
return self._file_response(path, **options)file_web_response#
file_web_response(file, **options) -> Effect[HttpServerResponse]A response streaming the file-like file, with an etag
and a last-modified header; offset, bytes_to_read and
chunk_size pick the range and its chunks, and the other options
go on the response. Never fails.
| Parameter | Type | Description |
|---|---|---|
file | FileLike | |
options | Unpack[FileWebOptions] = {} |
Returns Effect[HttpServerResponse]
def file_web_response(
self, file: FileLike, **options: Unpack[FileWebOptions]
) -> Effect[HttpServerResponse]:
"""A response streaming the file-like ``file``, with an ``etag``
and a ``last-modified`` header; ``offset``, ``bytes_to_read`` and
``chunk_size`` pick the range and its chunks, and the other options
go on the response. Never fails."""
return self._file_web_response(file, **options)