Document the Trailer response header in the trailers example

This commit is contained in:
Marcelo Trylesinski 2026-04-19 12:41:43 +02:00
parent 6cf4765b40
commit 23ef7d5ddb

View File

@ -181,6 +181,9 @@ body completes. Set `more_trailers` to `False` on the last trailers message.
Trailers are only emitted on the wire when the client sends a `TE: trailers` request header. When
the client does not advertise support, trailers sent by the application are silently dropped.
Applications should also announce the trailer field names in advance via the `Trailer` response
header, per [RFC 7230][rfc-7230-trailer].
```python
async def app(scope, receive, send):
assert scope['type'] == 'http'
@ -189,6 +192,7 @@ async def app(scope, receive, send):
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
[b'trailer', b'x-app-status'],
],
'trailers': True,
})
@ -205,6 +209,8 @@ async def app(scope, receive, send):
})
```
[rfc-7230-trailer]: https://www.rfc-editor.org/rfc/rfc7230#section-4.4
[http-trailers]: https://asgi.readthedocs.io/en/latest/extensions.html#http-trailers
---