cgi.FieldStorage and REDIRECT_REQUEST_METHOD
Austyn Bontrager
austynjay at yahoo.com
Tue Jul 27 20:38:30 EDT 2004
More information about the Python-list mailing list
Tue Jul 27 20:38:30 EDT 2004
- Previous message (by thread): cgi.FieldStorage and REDIRECT_REQUEST_METHOD
- Next message (by thread): Test failures on AIX 5.1 for 2.3.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Should cgi.FieldStorage examine the environment variable REDIRECT_REQUEST_METHOD before examining REQUEST_METHOD? I'm running Apache, and write my CGI scripts in Python. I have this in a /techdocs/.htaccess file: ErrorDocument 401 /forms/registration.cgi Require valid-user The registration script contains a <form method="POST">, so it submits back to itself. So a typical conversation goes like this: > GET /techdocs/usermanual.pdf HTTP/1.1 < HTTP/1.1 401 Unauthorized (browser pops up login box and user types something in username field) > GET /techdocs/usermanual.pdf HTTP/1.1 > Authorization: Basic YWFhYTo= < HTTP/1.1 200 OK < <html><body><form method="POST"> ... </form></body></html> > POST /techdocs/usermanual.pdf HTTP/1.1 > Authorization: Basic YWFhYTo= > Content-Type: application/x-www-form-urlencoded > username=joe&email=joe at mailinator.com < HTTP/1.1 200 OK < <html><body>Thanks for registering. Log in as "joe" to < <a href="">Download</a> the file.</body></html> (user clicks on that Download link) > GET /techdocs/usermanual.pdf HTTP/1.1 > Authorization: Basic YWFhYTo= < HTTP/1.1 200 OK < Content-type: application/x-pdf < ... So after the POST, in my script I'd expect env variable REQUEST_METHOD to be "POST". However, REQUEST_METHOD is "GET", and REDIRECT_REQUEST_METHOD is "POST", and cgi.FieldStorage can't find the form values. I'm working around it by putting at the top of my script: RRM = "REDIRECT_REQUEST_METHOD" if os.environ.get(RRM) os.environ["REQUEST_METHOD"] = os.environ.get(RRM) Any better ideas? Should this be added to the cgi module (I think it's specific to Apache)? Should I ask this question somewhere else? Thanks Austyn
- Previous message (by thread): cgi.FieldStorage and REDIRECT_REQUEST_METHOD
- Next message (by thread): Test failures on AIX 5.1 for 2.3.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list