You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

querystring_parser.js 740B

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