I want to do stuff depending on headers in a middleware wrapped_receive, so far I'm doing something like:
async def wrapped_send(message: HTTPSendMessage) -> None:
if message["type"] == "http.response.start":
headers = dict(message["headers"])
if headers[b"content-type"].decode().partition(";")[0] != "text/html":
do_something()
if headers.get(b"transfer-encoding") == b"chunked":
do_another()
I wondered if there was a more "Litestar way" to do that, for instance I could probably replace by headers = dict(message["headers"]) by headers = dict(MutableScopeHeaders.from_message(message=message).headers but that's not that shorter or clearer,