From 6ecfba9a2b3a1cdcbc04179f452c5e03d5c394f2 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Sat, 3 Oct 2020 13:38:02 -0400 Subject: [PATCH] Generalize media type parsing to handle parameters --- fastapi/routing.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index 8b185d1eaf5e7..57fbbf9662cea 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -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