Skip to content

Commit

Permalink
[PR #7283/0e7c272f backport][3.9] Add note about updating headers in …
Browse files Browse the repository at this point in the history
…on_response_prepare (#7294)

**This is a backport of PR #7283 as merged into master
(0e7c272).**

Fixes #6443.

It seems like it'll be easier just to document this. Only solution that
looks like it'd work is to update the Content-Length header every time
the body is changed, but that could incur a performance penalty for
little reason.

Co-authored-by: Sam Bull <[email protected]>
  • Loading branch information
patchback[bot] and Dreamsorcerer authored May 17, 2023
1 parent 9258d34 commit 3de86c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/7283.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a note about possibly needing to update headers when using ``on_response_prepare`` -- by :user:`Dreamsorcerer`
7 changes: 7 additions & 0 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,13 @@ duplicated like one using :meth:`~aiohttp.web.Application.copy`.
async def on_prepare(request, response):
pass

.. note::

The headers are written immediately after these callbacks are run.
Therefore, if you modify the content of the response, you may need to
adjust the `Content-Length` header or similar to match. Aiohttp will
not make any updates to the headers from this point.

.. attribute:: on_startup

A :class:`~aiosignal.Signal` that is fired on application start-up.
Expand Down

0 comments on commit 3de86c1

Please sign in to comment.