[nodejs] cancel fileupload, send error back immediately

hello, i'm using node v 6.9.13this is bugging me for a while now, how can i cancel a ongoing fileuploadand send the error back immediately?for example if the file is too large i don't want the user to wait until hehas finaly uploaded his file to get a proper error message.

i tried req.client.destroy() but haven't had any success passing a messageback, status in chrome says only "failed".

Search Discussions

2 responses

Coffeecupmy node version is 0.6.13 not 6.9.13 :) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en

HasanyasinI was searching something and saw this post. It has been months since it was asked; but I wanted to write an answer so even if you don't need it anymore, someone looking for this can benefit... This is the way http is designed so there is nothing you can do to change this behavior. You cannot stop a request and return response body. First, request headers and body are completely sent to server then response headers and body are sent back to client. If you don't want to accept such files to

I was searching something and saw this post. It has been months since itwas asked; but I wanted to write an answer so even if you don't need itanymore, someone looking for this can benefit...

This is the way http is designed so there is nothing you can do to changethis behavior. You cannot stop a request and return response body. First,request headers and body are completely sent to server then responseheaders and body are sent back to client. If you don't want to accept suchfiles to prevent unnecessary load and bandwidth costs, just drop theconnection and let the client figure out what they did wrong.

HTTP works like this; but web applications don't have to. If this is a webapplication, you can check what is wrong on client side. If there arethings that you can only check at server-side, you can have multipleconnections to the server and while sending a request on one connection,you can ask for status info for this big request on another connection...