It's a pity that browsers couldn't just tell you the length of the part in the header of each part.
But afaik, that's pretty much never the case with file uploads, unless you are uploading a file that is still growing in size - so yeah, it's annoying : ).
('felixge2' because my other account is in noprocrast mode: )
If a connection is closed, either by a timeout, or EOF, you simply check if the promised content length matches the count of received bytes - if not you should probably discard the whole thing (unless you're specifically supporting broken clients).