REDIRECT_REQUES T_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.cg i
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><fo rm method="POST"> ... </form></body></html>
POST /techdocs/usermanual.pdf HTTP/1.1
Authorization: Basic YWFhYTo=
Content-Type: application/x-www-form-urlencoded
us************* *******@mailina tor.com
< HTTP/1.1 200 OK
< <html><body>Tha nks for registering. Log in as "joe" to
< <a href="">Downloa d</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_REQUES T_METHOD is "POST", and cgi.FieldStorag e can't find the
form values.
I'm working around it by putting at the top of my script:
RRM = "REDIRECT_REQUE ST_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