From 0d761afe3f6bbf36a68994cfc406e39bc7cefb04 Mon Sep 17 00:00:00 2001 From: Diogo Martins Date: Sat, 14 Feb 2026 16:03:12 +0000 Subject: [PATCH] Fix Lighttpd implementation to echo body on POST / --- docs/content/servers/lighttpd.md | 12 ++++++++++++ src/Servers/LighttpdServer/index.cgi | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/content/servers/lighttpd.md b/docs/content/servers/lighttpd.md index 9477774..f35a812 100644 --- a/docs/content/servers/lighttpd.md +++ b/docs/content/servers/lighttpd.md @@ -31,6 +31,18 @@ server.error-handler = "/index.cgi" alias.url = ("/echo" => "/var/www/echo.cgi") ``` +## Source — `index.cgi` + +```bash +#!/bin/sh +printf 'Content-Type: text/plain\r\n\r\n' +if [ "$REQUEST_METHOD" = "POST" ] && [ "${CONTENT_LENGTH:-0}" -gt 0 ] 2>/dev/null; then + head -c "$CONTENT_LENGTH" +else + printf 'OK' +fi +``` + ## Source — `echo.cgi` ```bash diff --git a/src/Servers/LighttpdServer/index.cgi b/src/Servers/LighttpdServer/index.cgi index 8c23b46..78df354 100644 --- a/src/Servers/LighttpdServer/index.cgi +++ b/src/Servers/LighttpdServer/index.cgi @@ -1,7 +1,7 @@ #!/bin/sh printf 'Content-Type: text/plain\r\n\r\n' -if [ "$REQUEST_METHOD" = "POST" ]; then - cat +if [ "$REQUEST_METHOD" = "POST" ] && [ "${CONTENT_LENGTH:-0}" -gt 0 ] 2>/dev/null; then + head -c "$CONTENT_LENGTH" else printf 'OK' fi