If I were you, I would make an architectural change on system. 1. If I have control on how clients will work, I would definitely divide this into two requests. First client authorizes itself, I turn back a session key and keep it on memory to quickly look it up for the stream authorization. When stream starts, headers include this and I can do authorization very quickly synchronously.
2. If I have no control on how clients will work, I would connect the incoming stream to target stream immediately before the authorization check is done. This time, I would be redesigning how target stream works, instead of how client connects. Target stream can easily have a drop_no_auth method or maybe it can be a middleman buffering incoming data until I tell it to flow to real target when authorization is done. On Thursday, June 28, 2012 11:28:10 AM UTC-4, Domenic Denicola wrote: > > The scenario I'm trying to solve is: > * Get an incoming HTTP request stream > * Look at the headers and use them to do some authorization logic, > asynchronously > * When that logic returns successfully, pipe the request stream to > another stream > * When that logic returns a failure, discard the incoming request stream > and don't leak memory. > -- 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
