Authored by 周奇琪

如果是数组的form数据,使用querystring提交

... ... @@ -68,9 +68,8 @@ module.exports = function(proxyRoute) {
options.headers['Referer'] = req.headers['referer'];
}
if(isFromArray(req.body)) {
options.method = "GET";
options.url += "?"+ queryString.stringify(req.body);
if(isFromArray(req.body)) { //如果是数组的form表单,使用querystring序列化
options.useQuerystring = true;
}
//如果是POST,设置form表单的传参
... ... @@ -81,10 +80,10 @@ module.exports = function(proxyRoute) {
logger.log('info','grayroute: request options: %j',options,{});
//发起代理请求
if(req.is('html')) { //如果是静态资源
if(req.is('html')) {
request(options,callback);
} else {
request(options).pipe(ress);
request(options).pipe(ress);//如果是静态资源,直接管道传递结果
}
//代理回调
... ... @@ -146,6 +145,11 @@ module.exports = function(proxyRoute) {
return cookie;
}
/**
* 判断是否是数组的form表单
* @param {[type]} form [description]
* @return {Boolean} [description]
*/
function isFromArray(form) {
form = form||{};
var ret = false;
... ...
... ... @@ -12,7 +12,6 @@
"handlebars-layouts": "^3.1.3",
"ipaddr.js": "^1.1.0",
"lodash": "^3.10.0",
"query-string": "^3.0.1",
"request": "^2.55.0",
"yo.js": "^1.1.3"
},
... ...