Skip to content

Commit

Permalink
Document web.FileResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Transfusion authored and webknjaz committed Aug 19, 2019
1 parent 9e0fa0a commit 7a59a14
Show file tree
Hide file tree
Showing 2 changed files with 28 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``.
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

0 comments on commit 7a59a14

Please sign in to comment.