proc: inhibit chunked transfer encoding on existing TEs or known length
authorJo-Philipp Wich <[email protected]>
Sat, 5 Apr 2025 12:28:34 +0000 (14:28 +0200)
committerJo-Philipp Wich <[email protected]>
Sat, 5 Apr 2025 12:32:36 +0000 (14:32 +0200)
When a backend CGI, Lua or ucode handler produces a response which either
includes a Content-Length or a Transfer-Encoding header then disable the
uhttpd side chunked transfer encoding and assume the backend response to
be already properly encoded or length delimitted.

Fixes: https://github.com/openwrt/luci/issues/7655
Signed-off-by: Jo-Philipp Wich <[email protected]>
proc.c

diff --git a/proc.c b/proc.c
index 2b69703a07106066fccfa71a3f01363454398e93..89fe320ee35895984d804b3656d31f541b8eb26a 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -218,6 +218,10 @@ static void proc_handle_header(struct relay *r, const char *name, const char *va
                cl->dispatch.proc.status_code = atoi(buf);
                return;
        }
+       else if (!strcasecmp(name, "Content-Length") ||
+                !strcasecmp(name, "Transfer-Encoding")) {
+               cl->request.disable_chunked = true;
+       }
 
        blobmsg_add_string(&cl->dispatch.proc.hdr, name, val);
 }