Encode form paramerers properly\n (#4836)

Superagent doesn't encode form parameters properly. For example it doesn't encode objects which contain array. The following is a failed test case:
var my_opts = {
  'storyId': 65441,
  'id': [56, 352]
};
This commit is contained in:
Hamed Ramezanian Nik
2017-03-03 08:48:11 +00:00
committed by wing328
parent 6c63558acc
commit b894dc3827
2 changed files with 10 additions and 10 deletions

View File

@@ -2,18 +2,18 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['superagent'], factory);
define(['superagent', 'querystring'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('superagent'));
module.exports = factory(require('superagent'), require('querystring'));
} else {
// Browser globals (root is window)
if (!root.{{moduleName}}) {
root.{{moduleName}} = {};
}
root.{{moduleName}}.ApiClient = factory(root.superagent);
root.{{moduleName}}.ApiClient = factory(root.superagent, root.querystring);
}
}(this, function(superagent) {
}(this, function(superagent, querystring) {
'use strict';
{{#emitJSDoc}} /**
@@ -383,7 +383,7 @@
}
if (contentType === 'application/x-www-form-urlencoded') {
request.send(this.normalizeParams(formParams));
request.send(querystring.stringify(this.normalizeParams(formParams)));
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {

View File

@@ -14,18 +14,18 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['superagent'], factory);
define(['superagent', 'querystring'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('superagent'));
module.exports = factory(require('superagent'), require('querystring'));
} else {
// Browser globals (root is window)
if (!root.SwaggerPetstore) {
root.SwaggerPetstore = {};
}
root.SwaggerPetstore.ApiClient = factory(root.superagent);
root.SwaggerPetstore.ApiClient = factory(root.superagent, root.querystring);
}
}(this, function(superagent) {
}(this, function(superagent, querystring) {
'use strict';
/**
@@ -386,7 +386,7 @@
}
if (contentType === 'application/x-www-form-urlencoded') {
request.send(this.normalizeParams(formParams));
request.send(querystring.stringify(this.normalizeParams(formParams)));
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {