From 25d7612f3889335ea2572353a7d00830689563fd Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Sat, 19 Feb 2011 21:50:28 +0000 Subject: [PATCH] lots of testing --- README.md | 83 +++++++++++++++++++ examples/client.js | 184 ++++++++++++++++++++++------------------- examples/php-server.js | 150 +++++++++++++++++++++------------ examples/server.js | 123 ++++++++++++++++----------- lib/fastcgi.js | 37 ++++----- 5 files changed, 370 insertions(+), 207 deletions(-) mode change 100644 => 100755 README.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 07583ff..ff44ad3 --- a/README.md +++ b/README.md @@ -29,3 +29,86 @@ A very basic FastCGI parser for low level parsing of the FastCGI protocol. Can b fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; } +# API + +fastcgi.parser + +parser.encoding = ["utf8"|"ascii"|"binary"] + +default is utf8. this determines the encoding used when reading the body of an STDIN/STDOUT/STDERR record. utf8 or ascii mean no onBody callback will be fired and the record in onRecord will have a body property set to the correctly encoded string. +binary will mean no body property is set on the record returned in the onRecord callback and chunks of the body will be emitted in the onBody callback as they arrive. + +parser.reset = function() + +resets the parser so it can be executed on a new stream. you should use this aftaer an error or when re-using an already existing parser on a new stream. + +parser.init = function() + +completely reinitialises the parser. calls parser.reset as well as setting encoding back to default (utf8) and clearing all callback handlers + +parser.execute = function(buffer) + +parses the buffer. calls callback. + +fastcgi.constants + + "version": 1, + "record": { + "FCGI_BEGIN": 1, + "FCGI_ABORT": 2, + "FCGI_END": 3, + "FCGI_PARAMS": 4, + "FCGI_STDIN": 5, + "FCGI_STDOUT": 6, + "FCGI_STDERR": 7, + "FCGI_DATA": 8, + "FCGI_GET_VALUES": 9, + "FCGI_GET_VALUES_RESULT": 10, + "FCGI_UNKNOWN_TYPE": 11 + }, + "keepalive": { + "OFF": 0, + "ON": 1 + }, + "parser": { + "state": { + "HEADER": 0, + "BODY": 1, + "PADDING": 2 + } + }, + "general": { + "FCGI_HEADER_LEN": 8, + "FCGI_MAX_BODY": Math.pow(2,16) + }, + "errors": { + "BUFFER_OVERFLOW": { + "err": 1, + "description": "buffer overflow" + }, + "MAX_BODY_EXCEEDED": { + "err": 2, + "description": "a body greater than maximum body size was read/written" + } + }, + "flags": { + "FCGI_KEEP_CONN": 1 + }, + "role": { + "FCGI_RESPONDER": 1, + "FCGI_AUTHORIZER": 2, + "FCGI_FILTER": 3 + }, + "protocol": { + "status": { + "FCGI_REQUEST_COMPLETE": 0, + "FCGI_CANT_MPX_CONN": 1, + "FCGI_OVERLOADED": 2, + "FCGI_UNKNOWN_ROLE": 3 + } + }, + "values": { + "FCGI_MAX_CONNS": "FCGI_MAX_CONNS", + "FCGI_MAX_REQS": "FCGI_MAX_REQS", + "FCGI_MPXS_CONNS": "FCGI_MPXS_CONNS" + } diff --git a/examples/client.js b/examples/client.js index c90c502..8afa9ca 100755 --- a/examples/client.js +++ b/examples/client.js @@ -7,109 +7,125 @@ var params = [ ["HTTP_ACCEPT_ENCODING", "none"], ["HTTP_CONNECTION", "Keep-Alive"], ["HTTP_ACCEPT", "*/*"], + ["HTTP_METHOD", "GET"], ["HTTP_HOST", "shuttle.owner.net:82"] ]; +var payload = new Buffer("hello"); var bytesin = 0; var bytesout = 0; var reqid = 0; +var keepalive = true; + +var clients = parseInt(process.ARGV[2] || 1); +var host = null; +var port = "/tmp/nginx.sock"; function writeSocket(socket, buffer) { bytesout += buffer.length; socket.write(buffer); } -function sendRequest(connection) { - reqid++; - connection.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_BEGIN, - "recordId": reqid, - "contentLength": 8, - "paddingLength": 0 - }); - connection.writer.writeBegin({ - "role": fastcgi.constants.role.FCGI_RESPONDER, - "flags": fastcgi.constants.keepalive.ON +var count = 0; +var recordId = 0; + +function client() { + var connection = new net.Stream(); + connection.setNoDelay(false); + connection.setTimeout(0); + + connection.addListener("connect", function() { + var writer = new fastcgi.writer(); + writer.encoding = "binary"; + var parser = new fastcgi.parser(); + parser.encoding = "binary"; + + var header = { + "version": fastcgi.constants.version, + "type": fastcgi.constants.record.FCGI_BEGIN, + "recordId": 0, + "contentLength": 0, + "paddingLength": 0 + }; + + var begin = { + "role": fastcgi.constants.role.FCGI_RESPONDER, + "flags": keepalive?fastcgi.constants.keepalive.ON:fastcgi.constants.keepalive.OFF + } + + var paramlen = fastcgi.getParamLength(params); + var FCGI_BEGIN = fastcgi.constants.record.FCGI_BEGIN; + var FCGI_PARAMS = fastcgi.constants.record.FCGI_PARAMS; + var FCGI_STDIN = fastcgi.constants.record.FCGI_STDIN; + var FCGI_END = fastcgi.constants.record.FCGI_END; + + connection.ondata = function (buffer, start, end) { + bytesin += (end-start); + parser.execute(buffer, start, end); + }; + + function sendRequest() { + header.type = FCGI_BEGIN; + header.recordId = reqid++; + header.contentLength = 8; + writer.writeHeader(header); + writer.writeBegin(begin); + writeSocket(connection, writer.tobuffer()); + header.type = FCGI_PARAMS; + header.contentLength = paramlen; + writer.writeHeader(header); + writer.writeParams(params); + writeSocket(connection, writer.tobuffer()); + header.contentLength = 0; + writer.writeHeader(header); + writeSocket(connection, writer.tobuffer()); + header.type = FCGI_STDIN; + //header.contentLength = 5; + //writer.writeHeader(header); + //writer.writeBody(payload); + //writeSocket(connection, writer.tobuffer()); + header.contentLength = 0; + writer.writeHeader(header); + writeSocket(connection, writer.tobuffer()); + if(!keepalive) connection.end(); + } + + parser.onRecord = function(record) { + recordId = record.header.recordId; + if(record.header.type == FCGI_END) { + count++; + if(keepalive) sendRequest(connection); + } + }; + parser.onError = function(err) { + console.log(JSON.stringify(err, null, "\t")); + }; + sendRequest(connection); }); - writeSocket(connection, connection.writer.tobuffer()); - connection.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_PARAMS, - "recordId": reqid, - "contentLength": fastcgi.getParamLength(params), - "paddingLength": 0 + + connection.addListener("timeout", function() { + connection.end(); }); - connection.writer.writeParams(params); - writeSocket(connection, connection.writer.tobuffer()); - connection.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_PARAMS, - "recordId": reqid, - "contentLength": 0, - "paddingLength": 0 + + connection.addListener("close", function() { + setTimeout(function() { + connection.connect(port, host); + }, 500); }); - writeSocket(connection, connection.writer.tobuffer()); - connection.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_STDIN, - "recordId": reqid, - "contentLength": 5, - "paddingLength": 0 + + connection.addListener("end", function() { }); - connection.writer.writeBody("hello"); - writeSocket(connection, connection.writer.tobuffer()); - connection.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_STDIN, - "recordId": reqid, - "contentLength": 0, - "paddingLength": 0 + + connection.addListener("error", function(exception) { + console.log(JSON.stringify(exception)); }); - writeSocket(connection, connection.writer.tobuffer()); + + connection.connect(port, host); } -var count = 0; -var recordId = 0; - -var connection = new net.Stream(); -connection.setNoDelay(true); -connection.setTimeout(0); - -connection.ondata = function (buffer, start, end) { - bytesin += (end-start); - connection.parser.execute(buffer.slice(start, end)); -}; - -connection.addListener("connect", function() { - connection.writer = new fastcgi.writer(); - connection.parser = new fastcgi.parser(); - connection.parser.onRecord = function(record) { - recordId = record.header.recordId; - count++; - if(record.header.type == fastcgi.constants.record.FCGI_END) { - sendRequest(connection); - } - }; - connection.parser.onError = function(err) { - console.log(JSON.stringify(err, null, "\t")); - }; - sendRequest(connection); -}); - -connection.addListener("timeout", function() { - connection.end(); -}); - -connection.addListener("close", function() { - connection.end(); -}); - -connection.addListener("error", function(exception) { - console.log(JSON.stringify(exception)); -}); - -connection.connect("/tmp/nginx.sock"); +while(clients--) { + setTimeout(client, 200); +} var then = new Date().getTime(); var last = 0; diff --git a/examples/php-server.js b/examples/php-server.js index 28fa486..85e8298 100755 --- a/examples/php-server.js +++ b/examples/php-server.js @@ -17,7 +17,7 @@ You can then run this example to fire requests at the php server You will need to change the SCRIPT_FILENAME param below to the full path of a script that is available to the php application */ var params = [ - ["SCRIPT_FILENAME", "/usr/share/nginx/html/mediawiki/config/index.php"], + ["SCRIPT_FILENAME", "/source/test.php"], ["QUERY_STRING", ""], ["REQUEST_METHOD", "GET"], ["CONTENT_TYPE", ""], @@ -42,83 +42,124 @@ var params = [ ["HTTP_HOST", "shuttle.owner.net:82"] ]; -var reqid = 0; +var requests = 0; +var keepalive = (process.ARGV[2] == "true"); +var responses = 0; +var recordId = 0; -function sendRequest(connection) { - try { - reqid++; - connection.writer.writeHeader({ +function client() { + var connection = new net.Stream(); + connection.setNoDelay(true); + connection.setTimeout(0); + var _recid = 0; + var writer = null; + var parser = null; + var plen = fastcgi.getParamLength(params); + var FCGI_RESPONDER = fastcgi.constants.role.FCGI_RESPONDER; + var FCGI_BEGIN = fastcgi.constants.record.FCGI_BEGIN; + var FCGI_STDIN = fastcgi.constants.record.FCGI_STDIN; + var FCGI_PARAMS = fastcgi.constants.record.FCGI_PARAMS; + var FCGI_END = fastcgi.constants.record.FCGI_END; + var header = { + "version": fastcgi.constants.version, + "type": FCGI_BEGIN, + "recordId": 0, + "contentLength": 0, + "paddingLength": 0 + }; + var begin = { + "role": FCGI_RESPONDER, + "flags": keepalive?fastcgi.constants.keepalive.ON:fastcgi.constants.keepalive.OFF + }; + + function sendRequest() { + requests++; + writer.writeHeader({ "version": fastcgi.constants.version, "type": fastcgi.constants.record.FCGI_BEGIN, - "recordId": reqid, + "recordId": requests, "contentLength": 8, "paddingLength": 0 }); - connection.writer.writeBegin({ + writer.writeBegin({ "role": fastcgi.constants.role.FCGI_RESPONDER, - "flags": fastcgi.constants.keepalive.OFF + "flags": keepalive?fastcgi.constants.keepalive.ON:fastcgi.constants.keepalive.OFF }); - connection.write(connection.writer.tobuffer()); - connection.writer.writeHeader({ + connection.write(writer.tobuffer()); + writer.writeHeader({ "version": fastcgi.constants.version, "type": fastcgi.constants.record.FCGI_PARAMS, - "recordId": reqid, + "recordId": requests, "contentLength": fastcgi.getParamLength(params), "paddingLength": 0 }); - connection.writer.writeParams(params); - connection.write(connection.writer.tobuffer()); - connection.writer.writeHeader({ + writer.writeParams(params); + connection.write(writer.tobuffer()); + writer.writeHeader({ "version": fastcgi.constants.version, "type": fastcgi.constants.record.FCGI_PARAMS, - "recordId": reqid, + "recordId": requests, "contentLength": 0, "paddingLength": 0 }); - connection.write(connection.writer.tobuffer()); - connection.writer.writeHeader({ + connection.write(writer.tobuffer()); + writer.writeHeader({ "version": fastcgi.constants.version, "type": fastcgi.constants.record.FCGI_STDIN, - "recordId": reqid, + "recordId": requests, "contentLength": 0, "paddingLength": 0 }); - connection.write(connection.writer.tobuffer()); + connection.write(writer.tobuffer()); } - catch(ex) { - connection.end(); +/* + function sendRequest() { + header.type = FCGI_BEGIN; + header.recordId = requests++; + header.contentLength = 8; + writer.writeHeader(header); + writer.writeBegin(begin); + connection.write(writer.tobuffer()); + header.type = FCGI_PARAMS; + header.contentLength = plen; + writer.writeHeader(header); + writer.writeParams(params); + connection.write(writer.tobuffer()); + header.contentLength = 0; + writer.writeHeader(header); + connection.write(writer.tobuffer()); + header.type = FCGI_STDIN; + writer.writeHeader(header); + connection.write(writer.tobuffer()); } -} - -var count = 0; -var recordId = 0; - -function client() { - var connection = new net.Stream(); - connection.setNoDelay(true); - connection.setTimeout(0); - +*/ connection.ondata = function (buffer, start, end) { - //console.log(JSON.stringify(buffer.slice(start, end), null, "\t")); - connection.parser.execute(buffer.slice(start, end)); + parser.execute(buffer, start, end); }; connection.addListener("connect", function() { - connection.writer = new fastcgi.writer(); - connection.parser = new fastcgi.parser(); - connection.parser.onRecord = function(record) { - console.log(JSON.stringify(record, null, "\t")); - count++; + writer = new fastcgi.writer(); + writer.encoding = "binary"; + parser = new fastcgi.parser(); + parser.encoding = "binary"; + + parser.onRecord = function(record) { + if(record.header.type == FCGI_END) { + responses++; + } recordId = record.header.recordId; }; - connection.parser.onHeader = function(header) { - if(header.type == fastcgi.constants.record.FCGI_STDOUT) { - sendRequest(connection); + parser.onHeader = function(header) { + if(keepalive) { + if(header.recordId != _recid) { + _recid = header.recordId; + sendRequest(connection); + } } }; - connection.parser.onError = function(err) { + parser.onError = function(err) { console.log(JSON.stringify(err, null, "\t")); }; sendRequest(connection); @@ -129,35 +170,34 @@ function client() { }); connection.addListener("end", function() { - //console.log("end"); - connection.destroy(); }); connection.addListener("close", function() { setTimeout(function() { - //console.log("reconnect"); - //connection.connect("/tmp/nginx.sock"); - //connection.connect(6000, "icms.owner.net"); - }, 0); + connection.connect(6000, "icms.owner.net"); + }, 100); }); - connection.addListener("error", function(exception) { - console.log(JSON.stringify(exception)); + connection.addListener("error", function(err) { + console.log(JSON.stringify(err)); connection.end(); }); connection.connect(6000, "icms.owner.net"); } -client(); +var clients = parseInt(process.ARGV[3] || 1); +while(clients--) { + client(); +} var then = new Date().getTime(); var last = 0; setInterval(function() { var now = new Date().getTime(); var elapsed = now - then; - var rps = count - last; - console.log("Record: " + recordId + ", Count: " + count + ", RPS: " + rps/(elapsed/1000)); + var rps = responses - last; + console.log("Requests: " + requests + ", Responses: " + responses + ", RPS: " + rps/(elapsed/1000)); then = new Date().getTime(); - last = count; + last = responses; }, 1000); diff --git a/examples/server.js b/examples/server.js index 7a7f249..16751d4 100755 --- a/examples/server.js +++ b/examples/server.js @@ -1,10 +1,25 @@ var net = require("net"); var fastcgi = require("../lib/fastcgi"); -var output = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 10\r\nContent-Type: text/plain\r\n\r\n0123456789"; +var payload = "hello"; +var message = { + "status": { + "status": 0, + "protocolStatus": 200 + }, + "body": new Buffer("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: " + payload.length + "\r\nContent-Type: text/plain\r\n\r\n" + payload), + "header": { + "version": fastcgi.constants.version, + "type": fastcgi.constants.record.FCGI_STDOUT, + "recordId": 0, + "contentLength": 0, + "paddingLength": 0 + } +}; var recordId = 0; -var count = 0; +var requests = 0; +var responses = 0; var connections = 0; var gconnections = 0; @@ -13,68 +28,80 @@ var bytesout = 0; function writeSocket(socket, buffer) { bytesout += buffer.length; - socket.write(buffer); + try { + socket.write(buffer); + } + catch(ex) { + console.log(ex); + } } var fcgid = net.createServer(function (socket) { socket.setTimeout(0); - socket.setNoDelay(true); + socket.setNoDelay(false); + var parser = new fastcgi.parser(); + parser.encoding = "binary"; + var writer = new fastcgi.writer(); + writer.encoding = "binary"; + + var FCGI_BEGIN = fastcgi.constants.record.FCGI_BEGIN; + var FCGI_PARAMS = fastcgi.constants.record.FCGI_PARAMS; + var FCGI_STDIN = fastcgi.constants.record.FCGI_STDIN; + var FCGI_END = fastcgi.constants.record.FCGI_END; + var FCGI_STDOUT = fastcgi.constants.record.FCGI_STDOUT; + socket.ondata = function (buffer, start, end) { bytesin += (end-start); - socket.parser.execute(buffer.slice(start, end)); + parser.execute(buffer, start, end); }; + + socket.on("error", function(err) { + console.log(err); + }); + + socket.addListener("close", function() { + connections--; + }); + socket.addListener("connect", function() { connections++; gconnections++; - socket.parser = new fastcgi.parser(); - socket.writer = new fastcgi.writer(); socket.keepalive = false; - socket.addListener("close", function() { - connections--; - }); - socket.parser.onError = function(exception) { + parser.onError = function(exception) { console.log(JSON.stringify(exception, null, "\t")); }; - socket.parser.onRecord = function(record) { + parser.onRecord = function(record) { + //console.log(record); recordId = record.header.recordId; - count++; switch(record.header.type) { - case fastcgi.constants.record.FCGI_BEGIN: + case FCGI_BEGIN: socket.keepalive = (record.body.flags == 1); break; - case fastcgi.constants.record.FCGI_PARAMS: + case FCGI_PARAMS: + if(record.header.contentLength == 0) { + message.header.type = FCGI_STDOUT; + message.header.recordId = recordId; + message.header.contentLength = message.body.length; + writer.writeHeader(message.header); + writer.writeBody(message.body); + writeSocket(socket, writer.tobuffer()); + + message.header.contentLength = 0; + writer.writeHeader(message.header); + writeSocket(socket, writer.tobuffer()); + + message.header.contentLength = 8; + message.header.type = FCGI_END; + writer.writeHeader(message.header); + writer.writeEnd(message.status); + writeSocket(socket, writer.tobuffer()); + + responses++; + } break; - case fastcgi.constants.record.FCGI_STDIN: + case FCGI_STDIN: if(record.header.contentLength == 0) { - socket.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_STDOUT, - "recordId": record.header.recordId, - "contentLength": output.length, - "paddingLength": 0 - }); - socket.writer.writeBody(output); - writeSocket(socket, socket.writer.tobuffer()); - socket.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_STDOUT, - "recordId": record.header.recordId, - "contentLength": 0, - "paddingLength": 0 - }); - writeSocket(socket, socket.writer.tobuffer()); - socket.writer.writeHeader({ - "version": fastcgi.constants.version, - "type": fastcgi.constants.record.FCGI_END, - "recordId": record.header.recordId, - "contentLength": 8, - "paddingLength": 0 - }); - socket.writer.writeEnd({ - "status": 0, - "protocolStatus": 200 - }); - writeSocket(socket, socket.writer.tobuffer()); + requests++; if(!socket.keepalive) { socket.end(); } @@ -93,10 +120,10 @@ var last = 0; setInterval(function() { var now = new Date().getTime(); var elapsed = (now - then)/1000; - var rps = count - last; - console.log("InRate: " + parseInt((((bytesin)/elapsed)*8)/(1024*1024)) + ", OutRate: " + parseInt((((bytesout)/elapsed)*8)/(1024*1024)) + ", Record: " + recordId + ", Count: " + count + ", RPS: " + rps/elapsed + ", A/Conn: " + connections + ", T/Conn: " + gconnections); + var rps = requests - last; + console.log("InRate: " + parseInt((((bytesin)/elapsed)*8)/(1024*1024)) + ", OutRate: " + parseInt((((bytesout)/elapsed)*8)/(1024*1024)) + ", Record: " + recordId + ", requests: " + requests + ", RPS: " + rps/elapsed + ", A/Conn: " + connections + ", T/Conn: " + gconnections); then = new Date().getTime(); - last = count; + last = requests; bytesin = 0; bytesout = 0; }, 1000); diff --git a/lib/fastcgi.js b/lib/fastcgi.js index 6168b63..9c7a280 100755 --- a/lib/fastcgi.js +++ b/lib/fastcgi.js @@ -107,9 +107,11 @@ function Parser() { var _header = new Buffer(FCGI_HEADER_LEN); var _body = new Buffer(FCGI_MAX_BODY); + _parser.current = _record; + _parser.init = function() { _parser.encoding = "utf8"; - _parser.onRecord = _parser.onError = _parser.onHeader = _parser.onParam = null; + _parser.onRecord = _parser.onError = _parser.onHeader = _parser.onParam = _parser.onBody = function(){}; _parser.reset(); } @@ -130,9 +132,10 @@ function Parser() { _parser.init(); - _parser.execute = function(buffer) { - var blen = buffer.length; - for (var i = 0; i < blen; i++) { + _parser.execute = function(buffer, start, end) { + if(!start) start = 0; + if(!end) end = buffer.length; + for (var i = start; i < end; i++) { switch(_parser.state) { case HEADER: if(_loc == FCGI_HEADER_LEN - 1) { @@ -146,11 +149,11 @@ function Parser() { header.paddingLength = _header[j++]; _record.body = {}; if(_record.header.contentLength > 0) { - if(_parser.onHeader) _parser.onHeader(header); + _parser.onHeader(header); _parser.state = BODY; } else { - if(_parser.onRecord) _parser.onRecord(_record); + _parser.onRecord(_record); } _loc=0; } @@ -183,7 +186,9 @@ function Parser() { case FCGI_GET_VALUES_RESULT: var j = 0, name = "", value = "", vlen = 0, nlen = 0; _record.body.params = {}; - while(j < _record.header.contentLength) { + var rlen = _record.header.contentLength; + j = rlen; + while(j < rlen) { nlen = _body[j]; if(nlen >> 7 == 1) { nlen = ((_body[j++] << 24) + (_body[j++] << 16) + (_body[j++] << 8) + _body[j++]) & 0x7fffffff; @@ -203,12 +208,12 @@ function Parser() { j += (nlen + vlen); name = nv.substring(0, nlen); value = nv.substring(nlen); - if(_parser.onParam) _parser.onParam(name, value); + _parser.onParam(name, value); _record.body.params[name] = value; } else { - if(_parser.onError) _parser.onError(new Error(JSON.stringify(BUFFER_OVERRUN))); - j = _record.header.contentLength; + _parser.onError(new Error(JSON.stringify(BUFFER_OVERRUN))); + j = rlen; } } break; @@ -224,7 +229,7 @@ function Parser() { _record.body = _body.asciiSlice(0, _record.header.contentLength); break; default: - if(_parser.onBody) _parser.onBody(_body, 0, _record.header.contentLength); + _parser.onBody(_body, 0, _record.header.contentLength); break; } break; @@ -235,7 +240,7 @@ function Parser() { } break; } - if(_parser.onRecord) _parser.onRecord(_record); + _parser.onRecord(_record); _loc = 0; if(_record.header.paddingLength > 0) { _parser.state = PADDING; @@ -376,14 +381,6 @@ exports.parser = Parser; exports.writer = Writer; exports.constants = constants; -// used to determine length of params body. pass in array of param pairs as follows: -/* -var len = fastcgi.getParamLength([ - ["HTTP_USER_AGENT", maxbuff], - ["HTTP_ACCEPT_ENCODING", "none"], - ["HTTP_CONNECTION", "Keep-Alive"] -]); -*/ exports.getParamLength = function(params) { var size = 0; params.forEach(function(param) {