1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/http-server/minimal-http-server-cgi
Andy Green 8a7e0edb7d lws_spawn_piped: break out from cgi
The vfork optimized spawn, stdxxx and terminal handling in the cgi
implementation is quite mature and sophisticated, and useful for
other things unrelated to cgi.  Break it out into its own public
api under LWS_WITH_SPAWN, off by default.

Expand it so the parent wsi is optional, and the role and protocol
bindings for stdxxx pipes can be set.  Allow optional sul timeout
and external lws_dll2 owner for extant children.

Remove inline style from minimal http-server-cgi
2020-02-21 17:32:41 +00:00
..
CMakeLists.txt cleaning 2020-01-05 22:17:58 +00:00
minimal-http-server.c lws_spawn_piped: break out from cgi 2020-02-21 17:32:41 +00:00
my-cgi-script.sh lws_spawn_piped: break out from cgi 2020-02-21 17:32:41 +00:00
README.md cgi: minimal example 2019-11-20 05:20:59 +00:00

lws minimal http server-cgi

build

 $ cmake . && make

usage

This example runs a script ./my-cgi-script.sh when you vist /

The script dumps some information from /proc on stdout, which is proxied back to the browser, script output on stderr is printed in the console.

It's able to serve the script output over h1 using chunked encoding, and over h2 having stripped the chunked encoding from the script output.

 $ ./lws-minimal-http-server-cgi
[2019/11/18 16:31:29:5481] U: LWS minimal http server | visit http://localhost:7681
[2019/11/18 16:31:40:2176] N: CGI-stderr: lwstest script stderr: REQUEST_METHOD was GET

Visit http://localhost:7681