Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connection): Fix creation of FormMultiDict in Request.form to properly handle multi-keys #3639

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

provinzkraut
Copy link
Member

@provinzkraut provinzkraut commented Jul 21, 2024

Fix #3627 by properly handling the creation of FormMultiDict where multiple values are given for a single key, to make Request.form() match the behaviour of receiving form data via the data kwarg.


Before

@post("/")
async def handler(request: Request) -> Any:
    return (await request.form()).getall("foo")

with create_test_client(handler) as client:
    print(client.post("/", data={"foo": ["1", "2"]}).json()) # [["1", "2"]]

After

@post("/")
async def handler(request: Request) -> Any:
    return (await request.form()).getall("foo")

with create_test_client(handler) as client:
    print(client.post("/", data={"foo": ["1", "2"]}).json()) # ["1", "2"]

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.26%. Comparing base (592b77d) to head (14e77ac).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3639   +/-   ##
=======================================
  Coverage   98.25%   98.26%           
=======================================
  Files         328      328           
  Lines       14884    14890    +6     
  Branches     2366     2369    +3     
=======================================
+ Hits        14625    14631    +6     
  Misses        117      117           
  Partials      142      142           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3639

@provinzkraut provinzkraut merged commit 18d84d8 into main Jul 27, 2024
26 checks passed
@provinzkraut provinzkraut deleted the fix-3627 branch July 27, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: FormMultiDict is incorrectly created
2 participants