encode / starlette

The little ASGI framework that shines. 🌟
https://www.starlette.io/
BSD 3-Clause "New" or "Revised" License
10.31k stars 948 forks source link

Replace `dict` by `Mapping` on `HTTPException.headers` #2749

Closed rijenkii closed 1 week ago

rijenkii commented 2 weeks ago

Summary

See also: https://github.com/fastapi/fastapi/discussions/12786

HTTP Headers cannot be represented by a dict, as they can have duplicate entries. Example: Set-Cookie.

As such type of starlette.exceptions.HTTPException's headers field should be typing.Mapping instead of dict, just like starlette.responses.Response's headers field: https://github.com/encode/starlette/blob/c2e3a39b09a613553ee03586589ed9cd0fbf07f3/starlette/responses.py#L27-L38

Checklist