What I have:
I use node.js with express framework , and I create where I can upload files, I use node-formidable for this.
What a problem
My problem is that I cannot close the request if I find an error with the downloaded files. I want to check file types, size, etc. Therefore, I can upload the files I need, and the files are not actually downloaded, so I do not waste time.
So the problem is that I cannot stop the HTTP request.
What i tried
Here is what I have tried so far:
request.connection.destroy(); response.end('something went wrong...');
I assume that connection.destroy() interrupts the request, and I know this because it raises the form interrupt event form.on('abort', function(){ ... }) ). But the file is still loading, and the response does not arrive immediately after the file has been downloaded.
So, how do I close the HTTP request and send a message to the client?
EDIT: And something else, when I do not use response.end() , then it works, except that the Client is waiting for a response, this is strange: \
Adam
source share