Re: Question about dir_cgi.c and PATH_INFO]

Michiel Boland <[email protected]> Mon, 24 Jan 2005 17:13:44 +0100 (MET)
Newsgroups gmane.network.mathopd
Message-ID <Pine.GSO.4.61.0501241652230.6878@brakkenstein.nijmegen.internl.net>
>> Eek. The dir_cgi.c on the mathopd site is rather old. It should use
>> SCRIPT_NAME, rather than PATH_INFO. I have replaced it. The new version
>> should work ok.
>
> Thanks, it works wonderfully now!  Question, though: Why should it use
> SCRIPT_NAME instead of PATH_INFO?  Or, I guess, what was the purpose of
> PATH_INFO, why did SCRIPT_NAME take over, and where can I read more
> about that?

I believe the story is roughly as follows. The CGI standard [1] dictates 
that if you have a script, say, /cgi-bin/php, then anything in the URL 
following that script is passed as PATH_INFO.

Now, the CGI standard was written at a time when the only CGI scripts were 
of the form described above, where you had a dedicated directory for 
scripts. This directory was mapped to a URL using ScriptAlias, or whatever 
directive ncsa/cern/etc used.

Today the /cgi-bin nonsense has mostly disappeared I think; nowadays 
scripts are put in the same directory as viewable content, so one would 
have just

    /hello-world.php

instead of

    /cgi-bin/php/hello-world.php

Now to make hello-world.php work the same one would set PATH_INFO to 
/hello-world.php in both instances. IIS did this, so I copied that 
behaviour. But it sort-of clashes with the CGI specification. Since 
mathopd 1.5 is the first version that claims to support CGI properly I 
decided to back this out. Also, apache does it this way, and by then I no 
longer had anything to do with IIS. :)

Hope this makes any sense.

References:

[1] http://hoohoo.ncsa.uiuc.edu/cgi/

Cheers
Michiel