test-client: fix broken protocol names
[platform/upstream/libwebsockets.git] / test-server / lws-cgi-test.sh
index 2f5df11..cc14af2 100755 (executable)
@@ -1,18 +1,35 @@
 #!/bin/sh
 
-echo "lwstest script stdout"
->&2 echo "lwstest script stderr"
+echo -e -n "Content-type: text/html\x0d\x0a"
+echo -e -n "\x0d\x0a"
 
-echo "REQUEST_METHOD=$REQUEST_METHOD"
+echo "<html><body>"
+echo "<h1>lwstest script stdout</h1>"
+>&2 echo "lwstest script stderr: $REQUEST_METHOD"
+
+echo "<h2>REQUEST_METHOD=$REQUEST_METHOD</h2>"
 
 if [ "$REQUEST_METHOD" = "POST" ] ; then
-       read line
+       >&2 echo "lwstest script stderr: doing read"
+       echo "CONTENT_LENGTH=$CONTENT_LENGTH"
+       read -n $CONTENT_LENGTH line
+       >&2 echo "lwstest script stderr: done read"
+
        echo "read=\"$line\""
 else
-       cat /proc/meminfo
+       echo "<table>"
+       echo "<tr><td colspan=\"2\" style=\"font-size:120%;text-align:center\">/proc/meminfo</td></tr>"
+       cat /proc/meminfo | while read line ; do
+               A=`echo "$line" | cut -d: -f1`
+               B=`echo "$line" | tr -s ' ' | cut -d' ' -f2-`
+               echo -e "<tr><td style=\"background-color:#f0e8c0\">$A</td>"
+               echo -e "<td style=\"text-align:right\">$B</td></tr>"
+       done
+       echo "</table>"
 fi
 
-echo "done"
+echo "<br/>done"
+echo "</body></html>"
 
 exit 0