In short, "How"?
I read the RFC recommended,I know what I should prepare (and I already knew) for my script, but the question is how to send it to the script.
Do I send them via a pipe ? or command line with -??? switches, or what ? As far as web servers I've explored, I notice the only thing that need to tell the server is where the interpreter is (, and associate the application/type with file name extension). So what's the magic between ? | [reply] |
As you've read the RFC, maybe you can tell us what parts of chapter 3, Invoking the Script you've already implemented, and where your server still fails.
Update: Chapter 4.1, Request Meta-Variables tells me:
Meta-variables contain data about the request passed from the server
to the script, and are accessed by the script in a system-defined
manner.
The traditional system-defined manner is using the environment (%ENV) to pass these values. See also chapter 7, which discusses the different operating systems and their system-defined ways of communicating the variables to the child process.
| [reply] [d/l] |
In fact, I think that's nothing to do with RFC. A CGI script can be in Perl, Python, PHP, or whatever, it's the spec only, which is a "WHAT" but I am asking "HOW".
Consider I have already prepare everything (is needed for me at this moment, actually), but as said in my OP, the limitation is I have to do all the rest within my server's code. My server can communicate with the browser by all means.
I don't know "the how" is how to pass the parameters that I've prepared to my target CGI script, so when my CGI script got triggered, it's just naturally have all the %ENV variables ready or a opened STDIN is ready for read().
| [reply] |
I read the RFC recommended,I know what I should prepare (and I already knew) for my script, but the question is how to send it to the script.
client makes a request through socket , your server reads headers, then
Populate a local %ENV
dispatches/calls/invokes a process , through pipe, fork, whatever, see perlipc, Capture::Tiny
put http request BODY on STDIN
Collect output from STDOUT
log errors from STDERR
After timeout, or whatever,
return/generate/forward a return HTTP request back on socket to the client
I already linked examples in Re: How a web server sending data to a CGI perl script ?
| [reply] |
Thanks and I am still reading.... I can feel something and it's insightful indeed. Would be glad to hear more from your advise though :
1. Do you think rather send out the data to an external script, import the external code into the server and run it is a better approach (eg. require "script.pl") ?
2. Can you tell if when a web server claims it supports a certain language, it does have to implement something ( not just command line ) to prepare the environment ( meta ) variables for that particular language ?
| [reply] [d/l] |