, , , ...
, , . npm qs (https://npmjs.org/package/qs) , , "" '[n]'.
function stringifyArray(arr, prefix) {
var ret = [];
if (!prefix) throw new TypeError('stringify expects an object');
for (var i = 0; i < arr.length; i++) {
ret.push(stringify(arr[i], prefix + '[' + i + ']')); <<< see here
}
return ret.join('&');
}
, :
foo[0]=value0&foo[1]=value1
, , , , , , , HTML-. HTML , : -)
, node, querystring.stringify, , ,
foo=value0&foo=value1
- Request.form() ( 974)
this.body = *querystring*.stringify(form).toString('utf8')
, , , . . "" . , - ( "" ), index.js, factory request(). "" new request.js. : require('request/request.js')
: ( https://gist.github.com/MorganConrad/8827916)
var Request = require('request/request.js');
var querystring = require('querystring');
MyRequest.prototype = Object.create(Request.prototype);
MyRequest.prototype.constructor = MyRequest;
function MyRequest(options, callbackfn) {
"use strict";
if (callbackfn)
options.callback = callbackfn;
options.method = options.method || 'POST';
Request.prototype.constructor.call(this, options);
}
MyRequest.prototype.form = function (form) {
"use strict";
if (form) {
this.setHeader('content-type', 'application/x-www-form-urlencoded; charset=utf-8');
this.body = querystring.stringify(form).toString('utf8');
return this;
}
else
return Request.prototype.form.apply(this, arguments);
};
module.exports = MyRequest;