/http_utils.js

HTTP utils for node.js

Primary LanguageJavaScript

http_utils.js - An HTTP utility library for node.js
===================================================

If you're using HTTPServer in node.js, this library allows you to skip the tedious
argument parsing for GET, POST and multipart POST params, instead delivering them
ready-parsed into req.get and req.post objects.

Simple usage example:

    http_utils.createSimpleServer(function (req, res){

        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.write("GET params: "+sys.inspect(req.get)+"\n");
        res.write("POST params: "+sys.inspect(req.post)+"\n");
        res.write("FILES params: "+sys.inspect(req.files)+"\n");
        res.end();

    }).listen(1234);

Internally the library implements sub-header parsing and multipart decoding. You 
probably don't need to call any of that directly.



>>>>>>>> THIS IS A WORK IN PROGRESS <<<<<<<<

TODO: general clean up
TODO: file uploads never get cleaned up
TODO: file uploads all get placed as /tmp/node-* which is dumb
TODO: needs moar tests