Skip to content

Instantly share code, notes, and snippets.

@Marak
Created January 21, 2010 18:58
Show Gist options
  • Save Marak/283072 to your computer and use it in GitHub Desktop.
Save Marak/283072 to your computer and use it in GitHub Desktop.
http.createServer(function (req, resp) {
req.body = '';
req.addListener('data',function(chunk){
req.body += chunk
})
req.addListener('end', function(){
var httpParams = {};
req.uri = url.parse(req.url);
if(typeof req.uri.query == 'undefined'){req.uri.query = '';}
req.uri.params = querystring.parse(req.uri.query);
process.mixin(true, httpParams, req.uri.params);
process.mixin(true, httpParams, querystring.parse(req.body));
// request processing logic goes here
sys.puts('end of http request');
})
}).listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment