Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document web.FileResponse #3991

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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``.
27 changes: 27 additions & 0 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,33 @@ Response
*Content-Length* HTTP header.


FileResponse
^^^^^^^^^^^^^^

.. 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.

WebSocketResponse
^^^^^^^^^^^^^^^^^

Expand Down