Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
if (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
5
var querystring = require('querystring');
6
7
function QuerystringParser(maxKeys) {
8
this.maxKeys = maxKeys;
9
this.buffer = '';
10
}
11
exports.QuerystringParser = QuerystringParser;
12
13
QuerystringParser.prototype.write = function(buffer) {
14
this.buffer += buffer.toString('ascii');
15
return buffer.length;
16
};
17
18
QuerystringParser.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
28
29