raspberryGPIOhtmlserver/node_modules/formidable/lib/querystring_parser.js
node_modules/formidable/lib/querystring_parser.jsRaw
1if (global.GENTLY) require = GENTLY.hijack(require);
2
3// This is a buffering parser, not quite as nice as the multipart one.
4// If I find time I'll rewrite this to be fully streaming as well
5var querystring = require('querystring');
6
7function QuerystringParser(maxKeys) {
8 this.maxKeys = maxKeys;
9 this.buffer = '';
10};
11exports.QuerystringParser = QuerystringParser;
12
13QuerystringParser.prototype.write = function(buffer) {
14 this.buffer += buffer.toString('ascii');
15 return buffer.length;
16};
17
18QuerystringParser.prototype.end = function() {
19 var fields = querystring.parse(this.buffer, '&', '=', { maxKeys: this.maxKeys });
20 for (var field in fields) {
21 this.onField(field, fields[field]);
22 }
23 this.buffer = '';
24
25 this.onEnd();
26};
27