On Thu, Aug 01, 2002 at 02:42:02PM -0400, Neil Schemenauer wrote:
>
> Going on general principles, I think it would be better if Quixote did
> not mess with the SCRIPT_NAME and PATH_INFO environment variables.  Does
> anyone object if I change Quixote to stop doing this?  After the change
> SCRIPT_NAME should be the path to the Quixote application and PATH_INFO
I would actually like to see that change, too.
Another twist to this: SCRIPT_NAME is not always the path to the
application. REQUEST_URI == SCRIPT_NAME + PATH_INFO is not always
correct.  I have a setup where I'm getting this (before publish()
is called):
SCRIPT_NAME='/~rw/qtest.fcgi'
SCRIPT_URI='http://somewhere/testing/qtest.fcgi/'
SCRIPT_URL='/testing/qtest.fcgi/'
PATH_INFO='/'
REQUEST_URI='/testing/qtest.fcgi/'
My setup is:
OpenBSD 3.0
Apache/1.3.19 (Unix) mod_fastcgi/2.2.12 mod_ssl/2.8.4 OpenSSL/0.9.6b
plus suEXEC, UserDir (w/ ExecCGI), rewrite rules:
RewriteRule ^/~.* - [forbidden]
RewriteRule ^/testing/(.*) /~rw/$1 [last,passthrough]
The CGI/1.1 spec says:
SCRIPT_NAME
  A virtual path to the script being executed, used for self-referencing URLs.
...so I guess that's an Apache bug. I didn't get to try a newer version yet.
- Robin
The Apache specific fix I'm using is:
class MySessionPublisher(SessionPublisher):
    def publish(self,stdin,stdout,stderr,env):
        # fix for apache + suexec + rewrite + userdir
        try:
            requri = env["REQUEST_URI"]
            pinfo = env["PATH_INFO"]
            if requri[-len(pinfo):]==pinfo:
                env["SCRIPT_NAME"] = requri[:-len(pinfo)]
        except KeyError:
            pass
        # show path-relevant environment
        #print "-----"
        #for i in
["SCRIPT_NAME","SCRIPT_URI","SCRIPT_URL","PATH_INFO","REQUEST_URI"]:
        #    print "%s='%s'"%(i,env[i])
        SessionPublisher.publish(self,stdin,stdout,stderr,env)