Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: How a web server sending data to a CGI perl script ?

by exilepanda (Friar)
on Jan 21, 2016 at 08:55 UTC ( [id://1153250]=note: print w/replies, xml ) Need Help??


in reply to Re: How a web server sending data to a CGI perl script ?
in thread How a web server sending data to a CGI perl script ?

Um.. Not exactly what I am asking. Say, I fetched a URI from the client wanted "index.pl", then I want to *delegate* the query string , %ENV I've constructed in my server to index.pl for implementation, and I capture the result and return it to the client.

The meaning I said a CGI script don't need to concern... is that a CGI script can always code like this :

#!perl print "Content-Type: text/html\n\n"; print $ENV{REMOTE_ADDR};
The script don't need to care about the server is IIS or Apache...

Replies are listed 'Best First'.
Re^3: How a web server sending data to a CGI perl script ?
by Anonymous Monk on Jan 21, 2016 at 09:05 UTC

    It is exactly what you're asking. A server implementing CGI uses %ENV to communicate HTTP headers and other basic values (document_root)

    STDIN is used for the BODY of the HTTP request

    If this doesn't answer your question ... ask a different question please

      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 ?

        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.

        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 ?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153250]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found