diff --git a/supervisor/addons/model.py b/supervisor/addons/model.py index f8aca4446..5167ea908 100644 --- a/supervisor/addons/model.py +++ b/supervisor/addons/model.py @@ -32,6 +32,7 @@ from ..const import ( ATTR_HOST_PID, ATTR_IMAGE, ATTR_INGRESS, + ATTR_INGRESS_STREAM, ATTR_INIT, ATTR_JOURNALD, ATTR_KERNEL_MODULES, @@ -398,6 +399,11 @@ class AddonModel(CoreSysAttributes, ABC): """Return True if the add-on access support ingress.""" return None + @property + def ingress_stream(self) -> bool: + """Return True if post requests to ingress should be streamed.""" + return self.data[ATTR_INGRESS_STREAM] + @property def with_gpio(self) -> bool: """Return True if the add-on access to GPIO interface.""" diff --git a/supervisor/addons/validate.py b/supervisor/addons/validate.py index f9104dd6e..918fc4335 100644 --- a/supervisor/addons/validate.py +++ b/supervisor/addons/validate.py @@ -45,6 +45,7 @@ from ..const import ( ATTR_INGRESS_ENTRY, ATTR_INGRESS_PANEL, ATTR_INGRESS_PORT, + ATTR_INGRESS_STREAM, ATTR_INGRESS_TOKEN, ATTR_INIT, ATTR_JOURNALD, @@ -259,6 +260,7 @@ _SCHEMA_ADDON_CONFIG = vol.Schema( network_port, vol.Equal(0) ), vol.Optional(ATTR_INGRESS_ENTRY): str, + vol.Optional(ATTR_INGRESS_STREAM, default=False): vol.Boolean(), vol.Optional(ATTR_PANEL_ICON, default="mdi:puzzle"): str, vol.Optional(ATTR_PANEL_TITLE): str, vol.Optional(ATTR_PANEL_ADMIN, default=True): vol.Boolean(), diff --git a/supervisor/api/ingress.py b/supervisor/api/ingress.py index 5b86c880e..44c8d769d 100644 --- a/supervisor/api/ingress.py +++ b/supervisor/api/ingress.py @@ -167,7 +167,12 @@ class APIIngress(CoreSysAttributes): # 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() + # add-ons needs to add support with that in the configuration + data = ( + request.content + if request.method == "POST" and addon.ingress_stream + else await request.read() + ) async with self.sys_websession.request( request.method, diff --git a/supervisor/const.py b/supervisor/const.py index 3399d883e..901e5f13e 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -192,6 +192,7 @@ ATTR_INGRESS_PANEL = "ingress_panel" ATTR_INGRESS_PORT = "ingress_port" ATTR_INGRESS_TOKEN = "ingress_token" ATTR_INGRESS_URL = "ingress_url" +ATTR_INGRESS_STREAM = "ingress_stream" ATTR_INIT = "init" ATTR_INITIALIZE = "initialize" ATTR_INPUT = "input"