FAQ

[nodejs] cancel fileupload, send error back immediately

Coffeecup
Mar 16, 2012 at 9:21 pm
hello, i'm using node v 6.9.13
this is bugging me for a while now, how can i cancel a ongoing fileupload
and send the error back immediately?
for example if the file is too large i don't want the user to wait until he
has finaly uploaded his file to get a proper error message.

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





--
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
reply

Search Discussions

2 responses

  • Coffeecup at Mar 16, 2012 at 10:53 pm
    my 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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Hasanyasin at Jul 17, 2012 at 5:50 pm
    I 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 prevent unnecessary load and bandwidth costs, just drop the
    connection 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 web
    application, you can check what is wrong on client side. If there are
    things that you can only check at server-side, you can have multiple
    connections to the server and while sending a request on one connection,
    you can ask for status info for this big request on another connection...

    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Coffeecup: 2 posts Hasanyasin: 1 post