Skip to content

Commit

Permalink
Generalize media type parsing to handle parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Wang authored and patrickkwang committed Apr 10, 2021
1 parent d644c30 commit 6ecfba9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fastapi/routing.py
Expand Up @@ -180,9 +180,13 @@ async def app(request: Request) -> Response:
else:
body_bytes = await request.body()
if body_bytes:
if request.headers.get(
"Content-Type", "application/octet-stream"
).endswith("json"):
if (
request.headers.get(
"Content-Type", "application/octet-stream"
)
.split(";")[0]
.endswith("json")
):
body = await request.json()
else:
body = body_bytes
Expand Down

0 comments on commit 6ecfba9

Please sign in to comment.