Headers
and MutableHeaders
incorrectly assumes type of scope["headers"]
#1909
-
Looking at the It specifies:
However Starlette I've found that nginx unit (https://unit.nginx.org/) passes a tuple instead of a list, surfacing this issue. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Headers and MutableHeaders serve different purposes. Commonly, Headers is a read only struct that used by request.headers (scope['headers']) and not intended to be modifiable. The ASGI spec tells that headers are Iterable object (used in for-in like constructs). Starlette conforms this protocol. If you want to modify headers in middleware, I suggest converting scope['headers'] to MutableHeaders first. |
Beta Was this translation helpful? Give feedback.
-
How does #1917 look? |
Beta Was this translation helpful? Give feedback.
How does #1917 look?