diff --git a/CHANGES/3958.doc b/CHANGES/3958.doc new file mode 100644 index 00000000000..9f3a9de1743 --- /dev/null +++ b/CHANGES/3958.doc @@ -0,0 +1 @@ +Add documentation for ``aiohttp.web.FileResponse``. diff --git a/docs/web_reference.rst b/docs/web_reference.rst index 05f8085842d..f96fd59f56a 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -925,6 +925,31 @@ and :ref:`aiohttp-web-signals` handlers:: :attr:`~aiohttp.StreamResponse.body`, represented as :class:`str`. +.. class:: FileResponse(*, path, chunk_size=256*1024, status=200, reason=None, headers=None) + + The response class used to send files, inherited from :class:`StreamResponse`. + + Supports the ``Content-Range`` and ``If-Range`` HTTP Headers in requests. + + The actual :attr:`body` sending happens in overridden :meth:`~StreamResponse.prepare`. + + :param path: Path to file. Accepts both :class:`str` and :class:`pathlib.Path`. + :param int chunk_size: Chunk size in bytes which will be passed into + :meth:`io.RawIOBase.read` in the event that the + ``sendfile`` system call is not supported. + + :param int status: HTTP status code, ``200`` by default. + + :param str reason: HTTP reason. If param is ``None`` reason will be + calculated basing on *status* + parameter. Otherwise pass :class:`str` with + arbitrary *status* explanation.. + + :param collections.abc.Mapping headers: HTTP headers that should be added to + response's ones. The ``Content-Type`` response header + will be overridden if provided. + + .. class:: WebSocketResponse(*, timeout=10.0, receive_timeout=None, \ autoclose=True, autoping=True, heartbeat=None, \ protocols=(), compress=True, max_msg_size=4194304)