diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-13 20:55:11 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-13 20:55:11 +0300 |
commit | ca08ed93e67a99868f01d21f0d2e34d6a6757c75 (patch) | |
tree | 0475bec225b561f018b3d7b3d2961266c9d5b191 /examples/fcgi.c | |
parent | 23f3f8592c21ee58b0ac040736b5b766d52de193 (diff) | |
download | magi-ca08ed93e67a99868f01d21f0d2e34d6a6757c75.tar magi-ca08ed93e67a99868f01d21f0d2e34d6a6757c75.tar.xz magi-ca08ed93e67a99868f01d21f0d2e34d6a6757c75.zip |
[magi]
Diffstat (limited to 'examples/fcgi.c')
-rw-r--r-- | examples/fcgi.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/fcgi.c b/examples/fcgi.c new file mode 100644 index 0000000..5972cdd --- /dev/null +++ b/examples/fcgi.c @@ -0,0 +1,40 @@ +#include <fastcgi.h> +#include <request.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + + +void response_request(struct magi_request * req, struct magi_resopnse * res) +{ + magi_response_content_type(res, magi_xhtml); + magi_response_content(res, + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " + "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>" + "<html xmlns='http://www.w3.org/1999/xhtml'>" + "<head><title>Fast CGI</title></head>" + "<body>Hi!</body>" + "</html>"); +} + +int main(int argc, char const * argv[]) +{ + struct magi_session session; + if (magi_fcgi(&session)) { + struct magi_request request; + while (magi_accept(&request, &session)) { + if (!request.error) { + struct magi_response response; + response_request(&request, &response); + magi_fcgi_response(response); + magi_reponse_destroy(response); + } else { + magi_fcgi_error(request.error, &session); + } + magi_request_destroy(&request); + } + /* Fast CGI session error */ + } + /* Fast CGI session error */ + return 0; +} |