From 07eeb2eaf267094f47b4d4abdd7345abb3fee4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 29 Jun 2021 11:29:47 +0200 Subject: [PATCH] Only use .content for POST (#2981) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen Co-authored-by: Pascal Vizeli --- supervisor/api/ingress.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/supervisor/api/ingress.py b/supervisor/api/ingress.py index 0f761e06e..5b86c880e 100644 --- a/supervisor/api/ingress.py +++ b/supervisor/api/ingress.py @@ -164,13 +164,18 @@ class APIIngress(CoreSysAttributes): url = self._create_url(addon, path) source_header = _init_header(request, addon) + # Passing the raw stream breaks requests for some webservers + # since we just need it for POST requests really, for all other methods + # we read the bytes and pass that to the request to the add-on + data = request.content if request.method == "POST" else await request.read() + async with self.sys_websession.request( request.method, url, headers=source_header, params=request.query, allow_redirects=False, - data=request.content, + data=data, timeout=ClientTimeout(total=None), ) as result: headers = _response_header(result)