From 730de6afda78eef89677373baeab7694d01ae7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=2E=20K=C3=A4rkk=C3=A4inen?= Date: Wed, 4 Mar 2020 15:25:50 +0200 Subject: [PATCH] Default to no maximum request size for streaming handlers. --- sanic/app.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index b63b71cb..163e806d 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -993,12 +993,13 @@ class Sanic: # Fetch handler from router handler, args, kwargs, uri, name = self.router.get(request) - # Non-streaming handlers have their body preloaded - if ( - request.stream.request_body - and not self.router.is_stream_handler(request) - ): - await request.receive_body() + if request.stream.request_body: + if self.router.is_stream_handler(request): + # Streaming handler: lift the size limit + request.stream.request_max_size = float("inf") + else: + # Non-streaming handler: preload body + await request.receive_body() # -------------------------------------------- # # Request Middleware