Skip to content

Commit

Permalink
[3.10] Document web.FileResponse (#8490)
Browse files Browse the repository at this point in the history
Missed backport of PR #3991 by @Transfusion

(cherry picked from commit 7a59a14)
  • Loading branch information
steverep authored Jul 10, 2024
1 parent 1432099 commit 1e0d0e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/3958.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add documentation for ``aiohttp.web.FileResponse``.
25 changes: 25 additions & 0 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1e0d0e8

Please sign in to comment.