473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

cgi.FieldStorage and REDIRECT_REQUEST_METHOD

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
us********************@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
Jul 18 '05 #1
1 1784
On 2004-07-28, Austyn Bontrager <au*******@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
us********************@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

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fred Murray | last post by:
Hi all, When uploading a file ("input type=file"), FieldStorage usually behaves correctly, but every once in a while (every couple days?), it will suddenly start causing internal server errors. ...
1
by: Ames Andreas (MPA/DF) | last post by:
Hi, sorry for following-up to myself. Some remarks: 1) Please excuse the bogus original message. I wrote it a minute before I knocked off work and I promise to never do so again :-) 2)...
1
by: Ames Andreas (MPA/DF) | last post by:
Hi, I'm currently using Zope 2.7.2-0 which in turn uses cgi.FieldStorage from Python 2.3.4. FieldStorage can either build a 'list' or a 'file' to represent a request. Unfortunately it...
4
by: Derek Basch | last post by:
Given this FieldStorage object: FieldStorage(None, None, ) I am trying to cgi.urlencode the FieldStorage object to POST to another cgi script. The documentation for urlencode,...
3
by: Chris Curvey | last post by:
I can't be the first person to want to do this, but I also can't seem to find a solution. (Perhaps my Google skills are poor today.) How can I emulate cgi.FieldStorage() for my unit tests so that...
0
by: John Salerno | last post by:
I'm trying to use a for loop with a FieldStorage object and I get the following error. Can you not treat it like a dictionary, or am I writing the for loop incorrectly? for item in form: print...
7
by: John Salerno | last post by:
If I want to get all the values that are entered into an HTML form and write them to a file, is there some way to handle them all at the same time, or must FieldStorage be indexed by each specific...
2
by: alex | last post by:
I'm building a Resty interface and i'm trying to POST data from a web page via a normal web form with method="POST" in it's form tag. When i submit the data to my resource the variable $_SERVER...
4
by: arorap | last post by:
I've mod_php installed with Apache 2.2. In one of my folders, I'm using the cgihandler as the PythonHandler as my target host runs python only as CGI. Here cgi.FieldStorage() doesn't seem to work....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.