httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eli Marmor <mar...@netmask.it>
Subject Re: [PATCH] proposal to add interactive CGI module
Date Thu, 05 Oct 2006 10:34:20 GMT
+1
;-)
(for honesty sake, I asked Issac to code it, after I did a similar thing
to another CGI library...)

I want to add a temporary README (i.e. Executive Summary for busy
people...):

WHAT:
A patch against module_cgi.c, that causes any apreq-based CGI program to
become interactive when run by the user and not by a web server.

ORIGINAL BEHAVIOR:
Such CGI programs require a user running the program from an interactive
shell to manually populate the local environment with the appropriate
(QUERY_STRING, HTTP_COOKIE, CONTENT_LENGTH, etc) variables and prepare a
properly formatted POST body; Otherwise, apreq fails to work.

NEW BEHAVIOR:
If the CGI was invoked not by a web server, it will prompt the user with
the needed parameter names upon demand, and read the typed-in values
(note: the original behavior is kept if QUERY_STRING is defined).

AFFECTED APIs:
* cgi_body(_get)
* cgi_args(_get)
* cgi_jar(_get)
* cgi_param(s)
* apreq_handle_cgi

EFFECT:
If interactive_mode has been detected, the above APIs will type a prompt
on stdout and await parameter values to be entered on stdin (lazily),
rather than parsing the appropriate brigade/environment variables.

WHY:
1. Save the need to write 2 programs for each purpose (one CGI and one
   interactive).  The same program will handle both cases.
2. Allow easier debugging of CGI, by gdb etc.
3. Easier CGI-based scripting (one may write "echo joe | mycgi" rather
   than: "export QUERY_STRING='name=joe'; mycgi").
4. Extra behavior for existing programs without recompiling them.
5. Because it's cool  ;-)

DEMO:
Just run module/test_cgi.c with the the modified libapreq2.


-- 
Eli Marmor
marmor@netmask.it
Netmask (El-Mar) Internet Technologies Ltd.
__________________________________________________________
Tel.:   +972-9-766-1020          8 Yad-Harutzim St.
Fax.:   +972-9-766-1314          P.O.B. 7004
Mobile: +972-50-5237338          Kfar-Saba 44641, Israel

Mime
View raw message