lib/HeaderParser.js
function HeaderParser(cfg) {
  EventEmitter.call(this);

  var self = this;
  this.nread = 0;
  this.maxed = false;
  this.npairs = 0;
  this.maxHeaderPairs = (cfg && typeof cfg.maxHeaderPairs === 'number'
                         ? cfg.maxHeaderPairs
                         : MAX_HEADER_PAIRS);
  this.buffer = '';
  this.header = {};
  this.finished = false;
  this.ss = new StreamSearch(B_DCRLF);
  this.ss.on('info', function(isMatch, data, start, end) {
    if (data && !self.maxed) {
      if (self.nread + (end - start) > MAX_HEADER_SIZE) {
        end = (MAX_HEADER_SIZE - self.nread);
        self.nread = MAX_HEADER_SIZE;
      } else
        self.nread += (end - start);

      if (self.nread === MAX_HEADER_SIZE)
        self.maxed = true;

      self.buffer += data.toString('binary', start, end);
    }
    if (isMatch)
      self._finish();
  });
}
function HeaderParser(cfg) {
  EventEmitter.call(this);

  var self = this;
  this.nread = 0;
  this.maxed = false;
  this.npairs = 0;
  this.maxHeaderPairs = (cfg && typeof cfg.maxHeaderPairs === 'number'
                         ? cfg.maxHeaderPairs
                         : MAX_HEADER_PAIRS);
  this.buffer = '';
  this.header = {};
  this.finished = false;
  this.ss = new StreamSearch(B_DCRLF);
  this.ss.on('info', function(isMatch, data, start, end) {
    if (data && !self.maxed) {
      if (self.nread + (end - start) > MAX_HEADER_SIZE) {
        end = (MAX_HEADER_SIZE - self.nread);
        self.nread = MAX_HEADER_SIZE;
      } else
        self.nread += (end - start);

      if (self.nread === MAX_HEADER_SIZE)
        self.maxed = true;

      self.buffer += data.toString('binary', start, end);
    }
    if (isMatch)
      self._finish();
  });
}
function HeaderParser ( cfg ) { EventEmitter . call ( this ) ; var self = this ; this . nread = 0 ; this . maxed = false ; this . npairs = 0 ; this . maxHeaderPairs = ( cfg && typeof cfg . maxHeaderPairs === 'number' ? cfg . maxHeaderPairs : MAX_HEADER_PAIRS ) ; this . buffer = '' ; this . header = { } ; this . finished = false ; this . ss = new StreamSearch ( B_DCRLF ) ; this . ss . on ( 'info' , function ( isMatch , data , start , end ) { if ( data && ! self . maxed ) { if ( self . nread + ( end - start ) > MAX_HEADER_SIZE ) { end = ( MAX_HEADER_SIZE - self . nread ) ; self . nread = MAX_HEADER_SIZE ; } else self . nread += ( end - start ) ; if ( self . nread === MAX_HEADER_SIZE ) self . maxed = true ; self . buffer += data . toString ( 'binary' , start , end ) ; } if ( isMatch ) self . _finish ( ) ; } ) ; }
from node's http_parser
from node s http_parser