Check out Brendan’s code:
Will this work for large requests?
And:
Is socket.sendall guaranteed to succeed?
—
Grab the code from https://github.com/ctb/meep/tree/master/util/multi
git fetch git://github.com/ctb/meep.git master:multip
git checkout multip
and run it:
cd util/multi/
python threads.py
python forks.py
One uses threads to do parallel processing, the other uses processes (‘fork’). (The second may not work on Windows, come to think of it.)
—
Well, on one level, it’s really simple – just change forms to use POST instead
<FORM METHOD="POST" ...>
...
</FORM>
See: http://www.jmarshall.com/easy/http/#postmethod for server-side handling.
See:
Basically, for uploading files, you specify an encoding:
<FORM ENCTYPE="multipart/form-data" METHOD=POST>
...
</FORM>
and then the server needs to handle it specially.
The improper way to read POST data is to do it all at once.
Why is this a problem?
A better way is to read it in a stream.
We’ll talk about this in class a bit.