cgi.FieldStorage and REDIRECT_REQUEST_METHOD
Lee Harr
missive at frontiernet.net
Wed Jul 28 14:50:54 EDT 2004
More information about the Python-list mailing list
Wed Jul 28 14:50:54 EDT 2004
- Previous message (by thread): http://www.bisexualplayground.com/welcome.php?r=jon_mary420
- Next message (by thread): cgi.FieldStorage and REDIRECT_REQUEST_METHOD
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2004-07-28, Austyn Bontrager <austynjay at yahoo.com> wrote: > 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? > You might try here: http://python.org/sigs/web-sig/ http://mail.python.org/mailman/listinfo/web-sig or if you are pretty sure this is an apache only thing try: http://httpd.apache.org/lists.html
- Previous message (by thread): http://www.bisexualplayground.com/welcome.php?r=jon_mary420
- Next message (by thread): cgi.FieldStorage and REDIRECT_REQUEST_METHOD
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list