github.com/cloudcredo/cloudrocker@v0.0.0-20160108110610-1320f8cc2dfd/sample-apps/node/node_modules/logfmt/examples/post_to_express.js (about)

     1  var http   = require('http');
     2  
     3  var options = {
     4    hostname: 'localhost',
     5    port: 3000,
     6    path: '/logs',
     7    method: 'POST',
     8    headers: {
     9      'Content-Type':'application/logplex-1',
    10      'X-Request-ID':'D1908y1rl12k3jhaos9uy8a'
    11  
    12    }
    13  };
    14  
    15  var req = http.request(options, function(res) {
    16    console.log('STATUS: ' + res.statusCode);
    17    console.log('HEADERS: ' + JSON.stringify(res.headers));
    18    res.setEncoding('utf8');
    19    res.pipe(process.stdout)
    20    res.on('end', function() { process.exit(0) });
    21  });
    22  
    23  req.on('error', function(e) {
    24    console.log('problem with request: ' + e.message);
    25  });
    26  
    27  // write data to request body
    28  req.write('foo=bar a=14 baz="hello kitty" cool%story=bro f %^asdf\n');
    29  req.write('at=error code=H12 desc="Request timeout" method=GET path=/users/user38948@heroku.com/usage/2013-05-01T00:00:00Z/2013-05-01T00:00:00Z?exclude=platform%3Adyno%3Aphysical host=vault-usage-read.herokuapp.com fwd="50.17.15.69" dyno=web.21 connect=17ms service=30000ms status=503 bytes=0');
    30  req.end();