This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: CGIHTTPServer and urls
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, rhettinger, vincent_delft
Priority: normal Keywords:

Created on 2003-07-25 22:41 by vincent_delft, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Messages (5)
msg17341 - (view) Author: vincent delft (vincent_delft) Date: 2003-07-25 22:41
If you have 2 differents CGI.  
On the both you ask to print the content of cgi.FieldStorage. 
 
You will see that URL paramters (after ? in the url) remains. 
 
For our example : 
1) http://localhost:8080/cgi-bin/script1.py?action=test 
Will display the parameter name 'action' and his value 'test' 
BUT, now you ask the second url 
2) http://localhost:8080/cgi-bin/script2.py 
you still see the previous parameter 'action' with the previous 
value 'test' 
 
I've resolve the problem by removing a test in the 
CGIHTTPServer.py script. 
line +- 149 
-        if query: 
-            env['QUERY_STRING'] = query 
+       env['QUERY_STRING'] = query 
 
 
Indeed, the os.environ.update(env) does not modify 
'QUERY_STRING' if you are not givin a new value.   
But in this case empty is a new value, and must be take in 
account. 
 
I don't know if my resolution is the best one.  But now it works 
like it should be. 
 
 
msg17342 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-07-27 05:01
Logged In: YES 
user_id=80475

Will take a closer look at this one.  Initially, I was concerned 
that some CGI scripts check for the existence rather than the 
nullity of the QUERY_STRING key.  Now, I'm perplexed by 
why this isn't being handled by the for-loop (a few lines 
down from the part you patched) which "provides empty 
values to override previously set values".


msg17343 - (view) Author: vincent delft (vincent_delft) Date: 2003-07-27 11:53
Logged In: YES 
user_id=106404

I don't see the for-loop ?  
If you are talking about the following :  
        if not self.have_fork: 
            # Since we're setting the env in the parent, provide empty 
            # values to override previously set values 
            for k in ('QUERY_STRING', 'REMOTE_HOST', 
'CONTENT_LENGTH', 
                      'HTTP_USER_AGENT', 'HTTP_COOKIE'): 
                env.setdefault(k, "") 
 
 
It's normal that he not used because I'm on Linux machine. So, I have 
fork capabilities. 
Honestly I don't understand this loop. Indeed, You set to default values 
that was defined just before.  In general we set the default before. 
 
 
 
 
 
msg17344 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-08-17 17:09
Logged In: YES 
user_id=80475

Guido, is there a reason that you had excluded default 
setting when have_fork is true?
msg17345 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-03-20 22:29
Logged In: YES 
user_id=6380

Fixed in CVS for 2.4; will also for for 2.3.

I think I just had a black-out when I added the "if not
have_fork" test.

Note to vincent_delft: setdefault() only changes the value
if no value is already set, so it does exactly what we want.
History
Date User Action Args
2022-04-10 16:10:14adminsetgithub: 38933
2003-07-25 22:41:17vincent_delftcreate