Advertisement
Guest User

Untitled

a guest
Sep 29th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.use(function (req, res, next) {
  2.     var jl      = new JsonLoader();
  3.  
  4.     if(req.headers['content-encoding'] == 'deflate') {
  5.         req.pipe(zlib.createGunzip()).pipe(jl);
  6.     } else {
  7.         req.pipe(jl);
  8.     }
  9.  
  10.     req.once('data', function (chunk) {
  11.         var firstChunk = chunk.toString();
  12.         console.log(firstChunk.charAt(0));
  13.     });
  14.  
  15.     jl.on('data', function (obj) {
  16.         req.body = obj;
  17.     });
  18.  
  19.     jl.on('end', next);
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement