lib/helpers.js
function (req) {
    var keys = Object.keys(req.headers)

    var values = keys.map(function (key) {
      return req.headers[key]
    })

    var headers = req.method + req.url + keys.join() + values.join()

    // startline: [method] [url] HTTP/1.1\r\n = 12
    // endline: \r\n = 2
    // every header + \r\n = * 2
    // add 2 for each combined header
    return new Buffer(headers).length + (keys.length * 2) + 2 + 12 + 2
  }
function (req) {
    var keys = Object.keys(req.headers)

    var values = keys.map(function (key) {
      return req.headers[key]
    })

    var headers = req.method + req.url + keys.join() + values.join()

    // startline: [method] [url] HTTP/1.1\r\n = 12
    // endline: \r\n = 2
    // every header + \r\n = * 2
    // add 2 for each combined header
    return new Buffer(headers).length + (keys.length * 2) + 2 + 12 + 2
  }
function ( req ) { var keys = Object . keys ( req . headers ) var values = keys . map ( function ( key ) { return req . headers [ key ] } ) var headers = req . method + req . url + keys . join ( ) + values . join ( ) // startline: [method] [url] HTTP/1.1\r\n = 12 // endline: \r\n = 2 // every header + \r\n = * 2 // add 2 for each combined header return new Buffer ( headers ) . length + ( keys . length * 2 ) + 2 + 12 + 2 }
quickly calculates the header size in bytes for a given array of headers
quickly calculates the header size in bytes for a given array of headers