From d4a28a3337e6b5f2cd1a00698dad7264bc0c8cfe Mon Sep 17 00:00:00 2001 From: meestaben Date: Mon, 19 Feb 2024 11:46:08 +0000 Subject: [PATCH] Workaround for a new Odoo/werkzeug request restriction Short-term workaround for the problem described here: https://github.com/OCA/rest-framework/issues/414 --- fastapi/fastapi_dispatcher.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fastapi/fastapi_dispatcher.py b/fastapi/fastapi_dispatcher.py index 904deeff7..69ed724d6 100644 --- a/fastapi/fastapi_dispatcher.py +++ b/fastapi/fastapi_dispatcher.py @@ -43,7 +43,14 @@ def _make_response(self, status_mapping, headers_tuple, content): def _get_environ(self): environ = self.request.httprequest.environ - environ["wsgi.input"] = self.request.httprequest._get_stream_for_parsing() + wrapped_request = getattr( + self.request.httprequest, "_HTTPRequest__wrapped", None + ) + environ["wsgi.input"] = ( + wrapped_request._get_stream_for_parsing() + if wrapped_request + else self.request.httprequest._get_stream_for_parsing() + ) return environ @contextmanager