POST method, CGI and file transfer

M

Michael Foord

Another http question.
First one is simple - if a POST is made *to* a CGI with file uplaods
then you can get a FieldStorage with list values - each entry in the
list being a file. Two questions about this :
1) Is this the only situation you'll get list values posted to a CGI ?
If you have a list value in your FieldStorage instance can you be sure
that it's files ?
2) If a post is made of 1 file will it still be a list ? (jsut with a
single entry)

Admittedly the second one I could actually try... :)

More complicated - I want to proxy the file posts, i.e. extract them
from the FieldStorage and re-encode them to make another post from the
CGI. How do you encode multipart file posts - I couldn't see it
obviously from teh standard libraries. For ordinary data I would use
urllib.urlencode.

I saw one solution at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 but
this uses httplib and makes the post. I would *much* rather (if
possible) encode the files as headers in a Request object and use
urllib2 to make the post.

MANY TIA

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,191
Latest member
BuyKetoBeez

Latest Threads

Top