Imported Upstream version 3.2.0
[platform/upstream/libwebsockets.git] / test-apps / lws-cgi-test.sh
1 #!/bin/sh
2
3 echo -e -n "content-type: text/html\x0d\x0a"
4 echo -e -n "transfer-encoding: chunked\x0d\x0a"
5 echo -e -n "\x0d\x0a"
6
7 echo "<html><body>"
8 echo "<h1>lwstest script stdout</h1>"
9 >&2 echo "lwstest script stderr: $REQUEST_METHOD"
10
11 echo "<h2>REQUEST_METHOD=$REQUEST_METHOD</h2>"
12
13 if [ "$REQUEST_METHOD" = "POST" ] ; then
14         >&2 echo "lwstest script stderr: doing read"
15         echo "CONTENT_LENGTH=$CONTENT_LENGTH"
16         read -n $CONTENT_LENGTH line
17         >&2 echo "lwstest script stderr: done read"
18
19         echo "read=\"$line\""
20 else
21         echo "<table>"
22         echo "<tr><td colspan=\"2\" style=\"font-size:120%;text-align:center\">/proc/meminfo</td></tr>"
23         cat /proc/meminfo | while read line ; do
24                 A=`echo "$line" | cut -d: -f1`
25                 B=`echo "$line" | tr -s ' ' | cut -d' ' -f2-`
26                 echo -e "<tr><td style=\"background-color:#f0e8c0\">$A</td>"
27                 echo -e "<td style=\"text-align:right\">$B</td></tr>"
28         done
29         echo "</table>"
30 fi
31
32 echo "<br/>done"
33 echo "</body></html>"
34
35 exit 0
36