-- Read the entire available amount of data in one hit instead of forcing the data to be read in 512-byte chunks.

Kevin clearly intended to read as much data as was waiting, but select() returns the number of waiting filehandles, not # of waiting bytes.

Rather than reverting to the original 512 bytes per read, or ddavenport's suggested 1024, I used 1 MiB which is still arbitrary but large enough to get most normal http requests in few passes, and handles large uploads efficiently.