4 ms·
I think the reason multipart works that way, is so you can stream data that you don't know the full length of beforehand. But afaik, that's pretty much never t
by felixge2 16y ago
I think the reason multipart works that way, is so you can stream data that you don't know the full length of beforehand.
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: )
- stingraycharles 16y agoThink of it the other way too: it allows the HTTP server to start writing the file to disk without having to completely load the file into memory.
- felixge2 16y agoYou could still do that if the length was pre-announced, or am I missing something?
- stingraycharles 16y agoEhrm, yes, you're correct, I wasn't fully awake yet. I apologize.
- irrelative 16y agoYeah, you could -- I wonder what would happen if the client gets it wrong or is deliberately dishonest? Not trusting the client is a big part of writing an open server and this seems like you would have to trust the client in a big way.
- felixge2 16y agoWell, it's not a big problem - you should have a timeout on incoming connections, and node is pretty well-suited for having lots of "hanging" connections (I ran some test with 56k active connections). 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).