cs531-f19 / discussions

Discussions board for CS 431/531 Web Server Design course
2 stars 12 forks source link

env.cgi looking for STDIN #73

Open felixvelariusbos opened 4 years ago

felixvelariusbos commented 4 years ago

It looks like env.cgi has an continuous loop where it waits for STDIN and printing out anything it gets. It will never stop looking for more STDIN. I noticed this when I tried to run it and it started to hang:

while (<STDIN>) {
    print "$_<br>\n";
}

Looking at the RFCs, STDIN is an option to send in data, but we're choosing to use environment variables. In that case, is the goal of this loop being there to, basically, check if the server gracefully get out of it?

ibnesayeed commented 4 years ago

We do not send everything using environment variables. The payload in methods like POST and PUT (or any other method that allows entity body) is sent over STDIN. Query parameters, if any, are sent in environment variable, but that is not the only way of sending data to the server. The env.cgi script is written in a way to print every environment variable and any payload data, if present. If your server has nothing to be sent over STDIN, it can send None or empty bytes on it when executing the script process.