Check the sockread for "Content-Length: NNN" NNN is the filesize.