Skip to content

Replace dict by Mapping on HTTPException.headers#2749

Merged
Kludex merged 2 commits intoKludex:masterfrom
rijenkii:master
Nov 18, 2024
Merged

Replace dict by Mapping on HTTPException.headers#2749
Kludex merged 2 commits intoKludex:masterfrom
rijenkii:master

Conversation

@rijenkii
Copy link
Contributor

@rijenkii rijenkii commented Nov 11, 2024

Summary

See also: fastapi/fastapi#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

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex Kludex changed the title Fix type of HTTPException.headers Replace dict by Mapping on HTTPException.headers Nov 18, 2024
@Kludex Kludex merged commit cc1e2d7 into Kludex:master Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants