lib/server.js
function runNextRequest(){
		var self = this;

		var req = parser.read()
		if (req){
			var res = new Response(req);
			res.assignSocket(socket)

			//No matter how the response object gets closed this
			//will trigger the next one if there is one.
			res.once('close', function(){
				//Check if there is work.
				if(self.work){
					runNextRequest.call(self)
				} else {
					//Let the system know that you have stopped working
					self.working = false;
				}
			});

			this.emit('request', req, res);		
		}
	}
function runNextRequest(){
		var self = this;

		var req = parser.read()
		if (req){
			var res = new Response(req);
			res.assignSocket(socket)

			//No matter how the response object gets closed this
			//will trigger the next one if there is one.
			res.once('close', function(){
				//Check if there is work.
				if(self.work){
					runNextRequest.call(self)
				} else {
					//Let the system know that you have stopped working
					self.working = false;
				}
			});

			this.emit('request', req, res);		
		}
	}
function runNextRequest ( ) { var self = this ; var req = parser . read ( ) if ( req ) { var res = new Response ( req ) ; res . assignSocket ( socket ) //No matter how the response object gets closed this //will trigger the next one if there is one. res . once ( 'close' , function ( ) { //Check if there is work. if ( self . work ) { runNextRequest . call ( self ) } else { //Let the system know that you have stopped working self . working = false ; } } ) ; this . emit ( 'request' , req , res ) ; } }
This is the request processor loop using events to trigger the next request in the Queue.
This is the request processor loop using events to trigger the next request in the Queue .