Skip to content

Commit 8a3502e

Browse files
authored
Merge pull request #57 from MDA2AV/fix/lighttpd-post
Fix Lighttpd implementation to echo body on POST /
2 parents 53a8623 + 0d761af commit 8a3502e

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

docs/content/servers/lighttpd.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ server.error-handler = "/index.cgi"
3131
alias.url = ("/echo" => "/var/www/echo.cgi")
3232
```
3333

34+
## Source — `index.cgi`
35+
36+
```bash
37+
#!/bin/sh
38+
printf 'Content-Type: text/plain\r\n\r\n'
39+
if [ "$REQUEST_METHOD" = "POST" ] && [ "${CONTENT_LENGTH:-0}" -gt 0 ] 2>/dev/null; then
40+
head -c "$CONTENT_LENGTH"
41+
else
42+
printf 'OK'
43+
fi
44+
```
45+
3446
## Source — `echo.cgi`
3547

3648
```bash
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
printf 'Content-Type: text/plain\r\n\r\n'
3-
if [ "$REQUEST_METHOD" = "POST" ]; then
4-
cat
3+
if [ "$REQUEST_METHOD" = "POST" ] && [ "${CONTENT_LENGTH:-0}" -gt 0 ] 2>/dev/null; then
4+
head -c "$CONTENT_LENGTH"
55
else
66
printf 'OK'
77
fi

0 commit comments

Comments
 (0)