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

     1  #! /usr/bin/env node
     2  
     3  app = require('./express_buffered');
     4  var http = require('http');
     5  
     6  var options = {
     7    hostname: 'localhost',
     8    port: 3000,
     9    path: '/logs',
    10    method: 'POST',
    11    headers: {
    12      'Content-Type':'application/logplex-1'
    13    }
    14  };
    15  
    16  var req = http.request(options, function(res) {
    17    console.log('STATUS: ' + res.statusCode);
    18    console.log('HEADERS: ' + JSON.stringify(res.headers));
    19    res.setEncoding('utf8');
    20    res.on('data', function (chunk) {
    21      console.log('BODY: ' + chunk);
    22    });
    23    res.on('end', function(){
    24      console.log('end of request')
    25      process.exit(0);
    26    })
    27  });
    28  
    29  req.on('error', function(e) {
    30    console.log('problem with request: ' + e.message);
    31  });
    32  
    33  // write data to request body
    34  req.write('foo=bar a=14 baz="hello kitty" cool%story=bro f %^asdf\n');
    35  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\n');
    36  
    37  req.end();