2018-05-16 20:04:54 +08:00
|
|
|
const { isJson5, json_parse, handleJson, joinPath, safeArray } = require('./utils');
|
|
|
|
const constants = require('../client/constants/variable.js');
|
|
|
|
const _ = require('underscore');
|
|
|
|
const URL = require('url');
|
2018-02-08 16:03:14 +08:00
|
|
|
const utils = require('./power-string.js').utils;
|
2017-11-29 21:52:39 +08:00
|
|
|
const HTTP_METHOD = constants.HTTP_METHOD;
|
2018-02-08 21:29:10 +08:00
|
|
|
const axios = require('axios');
|
|
|
|
const qs = require('qs');
|
2017-11-29 21:52:39 +08:00
|
|
|
|
2018-02-08 21:29:10 +08:00
|
|
|
const isNode = typeof global == 'object' && global.global === global;
|
2017-11-29 21:52:39 +08:00
|
|
|
const ContentTypeMap = {
|
|
|
|
'application/json': 'json',
|
|
|
|
'application/xml': 'xml',
|
2018-05-16 20:04:54 +08:00
|
|
|
other: 'text',
|
2017-11-29 21:52:39 +08:00
|
|
|
'application/html': 'html'
|
2018-05-16 20:04:54 +08:00
|
|
|
};
|
2017-11-29 21:52:39 +08:00
|
|
|
|
2018-02-08 21:29:10 +08:00
|
|
|
async function httpRequestByNode(options) {
|
2018-05-16 20:04:54 +08:00
|
|
|
function handleRes(response) {
|
|
|
|
if (!response || typeof response !== 'object') {
|
2018-02-12 18:13:12 +08:00
|
|
|
return {
|
|
|
|
res: {
|
2018-04-11 20:13:29 +08:00
|
|
|
status: 500,
|
2018-05-16 20:04:54 +08:00
|
|
|
body: isNode
|
|
|
|
? '请求出错, 内网服务器自动化测试无法访问到,请检查是否为内网服务器!'
|
|
|
|
: '请求出错'
|
2018-02-12 18:13:12 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
};
|
2018-04-11 20:13:29 +08:00
|
|
|
}
|
|
|
|
return {
|
|
|
|
res: {
|
|
|
|
header: response.headers,
|
|
|
|
status: response.status,
|
|
|
|
body: response.data
|
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
};
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
|
|
|
|
2018-05-16 20:04:54 +08:00
|
|
|
function handleData() {
|
2018-02-08 21:29:10 +08:00
|
|
|
let contentTypeItem;
|
2018-05-16 20:04:54 +08:00
|
|
|
if (!options) return;
|
|
|
|
if (typeof options.headers === 'object' && options.headers) {
|
2018-02-08 21:29:10 +08:00
|
|
|
Object.keys(options.headers).forEach(key => {
|
|
|
|
if (/content-type/i.test(key)) {
|
2018-05-16 20:04:54 +08:00
|
|
|
if (options.headers[key]) {
|
|
|
|
contentTypeItem = options.headers[key]
|
|
|
|
.split(';')[0]
|
|
|
|
.trim()
|
|
|
|
.toLowerCase();
|
|
|
|
}
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
if (!options.headers[key]) delete options.headers[key];
|
|
|
|
});
|
|
|
|
|
|
|
|
if (
|
|
|
|
contentTypeItem === 'application/x-www-form-urlencoded' &&
|
|
|
|
typeof options.data === 'object' &&
|
|
|
|
options.data
|
|
|
|
) {
|
|
|
|
options.data = qs.stringify(options.data);
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
|
|
|
|
try {
|
2018-02-08 21:29:10 +08:00
|
|
|
handleData(options);
|
2018-05-16 20:04:54 +08:00
|
|
|
let response = await axios({
|
2018-02-08 21:29:10 +08:00
|
|
|
method: options.method,
|
|
|
|
url: options.url,
|
|
|
|
headers: options.headers,
|
|
|
|
timeout: 5000,
|
|
|
|
data: options.data
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
|
|
|
return handleRes(response);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.response === undefined) {
|
2018-02-12 18:13:12 +08:00
|
|
|
handleRes({
|
|
|
|
headers: {},
|
|
|
|
status: null,
|
|
|
|
data: err.message
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2018-02-12 18:13:12 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
return handleRes(err.response);
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
|
|
|
}
|
2017-12-04 21:32:09 +08:00
|
|
|
|
2017-11-29 21:52:39 +08:00
|
|
|
function handleContentType(headers) {
|
|
|
|
if (!headers || typeof headers !== 'object') return ContentTypeMap.other;
|
|
|
|
let contentTypeItem = 'other';
|
|
|
|
try {
|
|
|
|
Object.keys(headers).forEach(key => {
|
|
|
|
if (/content-type/i.test(key)) {
|
2018-05-16 20:04:54 +08:00
|
|
|
contentTypeItem = headers[key]
|
|
|
|
.split(';')[0]
|
|
|
|
.trim()
|
|
|
|
.toLowerCase();
|
2017-11-29 21:52:39 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2017-11-29 21:52:39 +08:00
|
|
|
return ContentTypeMap[contentTypeItem] ? ContentTypeMap[contentTypeItem] : ContentTypeMap.other;
|
|
|
|
} catch (err) {
|
2018-05-16 20:04:54 +08:00
|
|
|
return ContentTypeMap.other;
|
2017-11-29 21:52:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkRequestBodyIsRaw(method, reqBodyType) {
|
2018-05-16 20:04:54 +08:00
|
|
|
if (
|
|
|
|
reqBodyType &&
|
|
|
|
reqBodyType !== 'file' &&
|
|
|
|
reqBodyType !== 'form' &&
|
|
|
|
HTTP_METHOD[method].request_body
|
|
|
|
) {
|
2017-11-29 21:52:39 +08:00
|
|
|
return reqBodyType;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-22 17:04:20 +08:00
|
|
|
function checkNameIsExistInArray(name, arr) {
|
|
|
|
let isRepeat = false;
|
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
|
let item = arr[i];
|
|
|
|
if (item.name === name) {
|
2018-05-16 20:04:54 +08:00
|
|
|
isRepeat = true;
|
2017-12-22 17:04:20 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isRepeat;
|
|
|
|
}
|
|
|
|
|
2017-11-29 21:52:39 +08:00
|
|
|
function handleCurrDomain(domains, case_env) {
|
|
|
|
let currDomain = _.find(domains, item => item.name === case_env);
|
2018-05-21 20:01:28 +08:00
|
|
|
|
2017-11-29 21:52:39 +08:00
|
|
|
if (!currDomain) {
|
|
|
|
currDomain = domains[0];
|
|
|
|
}
|
|
|
|
return currDomain;
|
|
|
|
}
|
|
|
|
|
2018-05-16 20:04:54 +08:00
|
|
|
function sandboxByNode(sandbox = {}, script) {
|
2018-02-09 15:09:43 +08:00
|
|
|
const vm = require('vm');
|
|
|
|
script = new vm.Script(script);
|
|
|
|
const context = new vm.createContext(sandbox);
|
|
|
|
script.runInContext(context, {
|
|
|
|
timeout: 3000
|
|
|
|
});
|
|
|
|
return sandbox;
|
|
|
|
}
|
|
|
|
|
2018-05-16 20:04:54 +08:00
|
|
|
async function sandbox(context = {}, script) {
|
|
|
|
if (isNode) {
|
|
|
|
try {
|
2018-02-09 15:09:43 +08:00
|
|
|
context.context = context;
|
|
|
|
context.console = console;
|
2018-04-28 17:02:14 +08:00
|
|
|
context.Promise = Promise;
|
|
|
|
context.setTimeout = setTimeout;
|
2018-05-16 20:04:54 +08:00
|
|
|
context = sandboxByNode(context, script);
|
|
|
|
} catch (err) {
|
2018-02-09 15:09:43 +08:00
|
|
|
err.message = `Script: ${script}
|
2018-05-16 20:04:54 +08:00
|
|
|
message: ${err.message}`;
|
2018-02-09 15:09:43 +08:00
|
|
|
throw err;
|
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
} else {
|
|
|
|
context = sandboxByBrowser(context, script);
|
2018-02-09 15:09:43 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
if (context.promise && typeof context.promise === 'object' && context.promise.then) {
|
|
|
|
try {
|
|
|
|
await context.promise;
|
|
|
|
} catch (err) {
|
2018-04-28 17:02:14 +08:00
|
|
|
err.message = `Script: ${script}
|
2018-05-16 20:04:54 +08:00
|
|
|
message: ${err.message}`;
|
2018-04-28 17:02:14 +08:00
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
2018-02-09 15:09:43 +08:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sandboxByBrowser(context = {}, script) {
|
2017-12-05 15:13:31 +08:00
|
|
|
if (!script || typeof script !== 'string') {
|
2017-12-04 22:40:05 +08:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
let beginScript = '';
|
2017-12-05 15:13:31 +08:00
|
|
|
for (var i in context) {
|
2017-12-04 22:40:05 +08:00
|
|
|
beginScript += `var ${i} = context.${i};`;
|
|
|
|
}
|
2017-12-05 15:13:31 +08:00
|
|
|
try {
|
2017-12-04 22:40:05 +08:00
|
|
|
eval(beginScript + script);
|
2017-12-05 15:13:31 +08:00
|
|
|
} catch (err) {
|
2018-05-16 20:04:54 +08:00
|
|
|
let message = `Script:
|
|
|
|
----CodeBegin----:
|
|
|
|
${beginScript}
|
|
|
|
${script}
|
|
|
|
----CodeEnd----
|
|
|
|
`;
|
|
|
|
err.message = `Script: ${message}
|
|
|
|
message: ${err.message}`;
|
|
|
|
|
|
|
|
throw err;
|
2017-12-04 22:40:05 +08:00
|
|
|
}
|
|
|
|
return context;
|
2017-12-04 21:32:09 +08:00
|
|
|
}
|
|
|
|
|
2018-02-08 21:29:10 +08:00
|
|
|
async function crossRequest(defaultOptions, preScript, afterScript) {
|
2017-12-18 19:37:03 +08:00
|
|
|
let options = Object.assign({}, defaultOptions);
|
2018-05-16 20:04:54 +08:00
|
|
|
let urlObj = URL.parse(options.url, true),
|
|
|
|
query = {};
|
2017-12-04 22:40:05 +08:00
|
|
|
query = Object.assign(query, urlObj.query);
|
|
|
|
let context = {
|
2018-05-16 20:04:54 +08:00
|
|
|
get href() {
|
|
|
|
return urlObj.href;
|
|
|
|
},
|
|
|
|
set href(val){
|
|
|
|
throw new Error('context.href 不能被赋值')
|
|
|
|
},
|
|
|
|
get hostname() {
|
|
|
|
return urlObj.hostname;
|
|
|
|
},
|
|
|
|
set hostname(val){
|
|
|
|
throw new Error('context.hostname 不能被赋值')
|
|
|
|
},
|
2018-06-07 12:03:00 +08:00
|
|
|
|
|
|
|
get caseId() {
|
|
|
|
return options.caseId;
|
|
|
|
},
|
|
|
|
|
|
|
|
set caseId(val){
|
|
|
|
throw new Error('context.caseId 不能被赋值')
|
|
|
|
},
|
|
|
|
|
2018-03-14 11:26:40 +08:00
|
|
|
method: options.method,
|
2017-12-04 22:40:05 +08:00
|
|
|
pathname: urlObj.pathname,
|
|
|
|
query: query,
|
2017-12-05 15:13:31 +08:00
|
|
|
requestHeader: options.headers || {},
|
|
|
|
requestBody: options.data,
|
2018-05-16 20:04:54 +08:00
|
|
|
promise: false
|
2017-12-04 22:40:05 +08:00
|
|
|
};
|
2017-12-04 21:32:09 +08:00
|
|
|
|
2018-05-16 20:04:54 +08:00
|
|
|
context.utils = Object.freeze({
|
|
|
|
_: _,
|
|
|
|
base64: utils.base64,
|
|
|
|
md5: utils.md5,
|
|
|
|
sha1: utils.sha1,
|
|
|
|
sha224: utils.sha224,
|
|
|
|
sha256: utils.sha256,
|
|
|
|
sha384: utils.sha384,
|
|
|
|
sha512: utils.sha512,
|
|
|
|
unbase64: utils.unbase64,
|
|
|
|
axios: axios
|
|
|
|
})
|
|
|
|
|
2017-12-18 19:37:03 +08:00
|
|
|
if (preScript) {
|
2018-04-28 17:02:14 +08:00
|
|
|
context = await sandbox(context, preScript);
|
2017-12-18 19:37:03 +08:00
|
|
|
defaultOptions.url = options.url = URL.format({
|
|
|
|
protocol: urlObj.protocol,
|
|
|
|
host: urlObj.host,
|
|
|
|
query: context.query,
|
|
|
|
pathname: context.pathname
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2017-12-18 19:37:03 +08:00
|
|
|
defaultOptions.headers = options.headers = context.requestHeader;
|
|
|
|
defaultOptions.data = options.data = context.requestBody;
|
2017-12-04 21:32:09 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
|
2018-02-08 21:29:10 +08:00
|
|
|
let data;
|
2017-12-22 17:04:20 +08:00
|
|
|
|
2018-05-16 20:04:54 +08:00
|
|
|
if (isNode) {
|
|
|
|
data = await httpRequestByNode(options);
|
2018-02-08 21:29:10 +08:00
|
|
|
data.req = options;
|
2018-05-16 20:04:54 +08:00
|
|
|
} else {
|
|
|
|
data = await new Promise((resolve, reject) => {
|
|
|
|
options.error = options.success = function(res, header, data) {
|
2018-02-08 21:29:10 +08:00
|
|
|
let message = '';
|
2018-05-16 20:04:54 +08:00
|
|
|
if (res && typeof res === 'string') {
|
2018-02-09 15:09:43 +08:00
|
|
|
res = json_parse(data.res.body);
|
2018-02-08 21:29:10 +08:00
|
|
|
data.res.body = res;
|
|
|
|
}
|
|
|
|
if (!isNode) message = '请求异常,请检查 chrome network 错误信息...';
|
|
|
|
if (isNaN(data.res.status)) {
|
|
|
|
reject({
|
|
|
|
body: res || message,
|
|
|
|
header,
|
|
|
|
message
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
|
|
|
resolve(data);
|
2018-05-16 20:04:54 +08:00
|
|
|
};
|
2018-02-08 21:29:10 +08:00
|
|
|
window.crossRequest(options);
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2018-02-08 21:29:10 +08:00
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
|
2018-02-08 21:29:10 +08:00
|
|
|
if (afterScript) {
|
|
|
|
context.responseData = data.res.body;
|
|
|
|
context.responseHeader = data.res.header;
|
|
|
|
context.responseStatus = data.res.status;
|
|
|
|
context.runTime = data.runTime;
|
2018-04-28 17:02:14 +08:00
|
|
|
context = await sandbox(context, afterScript);
|
2018-02-08 21:29:10 +08:00
|
|
|
data.res.body = context.responseData;
|
|
|
|
data.res.header = context.responseHeader;
|
|
|
|
data.res.status = context.responseStatus;
|
|
|
|
data.runTime = context.runTime;
|
|
|
|
}
|
|
|
|
return data;
|
2017-11-29 21:52:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleParams(interfaceData, handleValue, requestParams) {
|
2018-06-13 13:59:36 +08:00
|
|
|
let interfaceRunData = Object.assign({}, interfaceData);
|
2017-11-29 21:52:39 +08:00
|
|
|
function paramsToObjectWithEnable(arr) {
|
|
|
|
const obj = {};
|
|
|
|
safeArray(arr).forEach(item => {
|
|
|
|
if (item && item.name && (item.enable || item.required === '1')) {
|
|
|
|
obj[item.name] = handleValue(item.value);
|
|
|
|
if (requestParams) {
|
|
|
|
requestParams[item.name] = obj[item.name];
|
|
|
|
}
|
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2017-11-29 21:52:39 +08:00
|
|
|
return obj;
|
|
|
|
}
|
2017-12-05 15:13:31 +08:00
|
|
|
|
2017-11-29 21:52:39 +08:00
|
|
|
function paramsToObjectUnWithEnable(arr) {
|
|
|
|
const obj = {};
|
|
|
|
safeArray(arr).forEach(item => {
|
|
|
|
if (item && item.name) {
|
|
|
|
obj[item.name] = handleValue(item.value);
|
|
|
|
if (requestParams) {
|
|
|
|
requestParams[item.name] = obj[item.name];
|
|
|
|
}
|
|
|
|
}
|
2018-05-16 20:04:54 +08:00
|
|
|
});
|
2017-11-29 21:52:39 +08:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2018-06-13 13:59:36 +08:00
|
|
|
let { case_env, path, env, _id } = interfaceRunData;
|
2018-05-16 20:04:54 +08:00
|
|
|
let currDomain,
|
|
|
|
requestBody,
|
|
|
|
requestOptions = {};
|
2017-11-29 21:52:39 +08:00
|
|
|
|
2018-06-13 13:59:36 +08:00
|
|
|
interfaceRunData.req_params = interfaceRunData.req_params || [];
|
|
|
|
interfaceRunData.req_params.forEach(item => {
|
2017-11-29 21:52:39 +08:00
|
|
|
let val = handleValue(item.value);
|
|
|
|
if (requestParams) {
|
|
|
|
requestParams[item.name] = val;
|
|
|
|
}
|
|
|
|
path = path.replace(`:${item.name}`, val || `:${item.name}`);
|
2017-12-07 10:38:41 +08:00
|
|
|
path = path.replace(`{${item.name}}`, val || `{${item.name}}`);
|
2017-11-29 21:52:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
currDomain = handleCurrDomain(env, case_env);
|
2017-12-04 21:32:09 +08:00
|
|
|
const urlObj = URL.parse(joinPath(currDomain.domain, path), true);
|
2017-11-29 21:52:39 +08:00
|
|
|
const url = URL.format({
|
|
|
|
protocol: urlObj.protocol || 'http',
|
|
|
|
host: urlObj.host,
|
|
|
|
pathname: urlObj.pathname,
|
2018-06-13 13:59:36 +08:00
|
|
|
query: Object.assign(urlObj.query, paramsToObjectWithEnable(interfaceRunData.req_query))
|
2017-11-29 21:52:39 +08:00
|
|
|
});
|
|
|
|
|
2018-06-13 13:59:36 +08:00
|
|
|
let headers = paramsToObjectUnWithEnable(interfaceRunData.req_headers);
|
2017-12-04 21:32:09 +08:00
|
|
|
requestOptions = {
|
|
|
|
url,
|
2018-06-07 12:03:00 +08:00
|
|
|
caseId: _id,
|
2018-06-13 13:59:36 +08:00
|
|
|
method: interfaceRunData.method,
|
|
|
|
headers,
|
2017-12-04 21:32:09 +08:00
|
|
|
timeout: 82400000
|
2018-05-16 20:04:54 +08:00
|
|
|
};
|
2017-12-04 21:32:09 +08:00
|
|
|
|
2018-06-13 13:59:36 +08:00
|
|
|
// 对 raw 类型的 form 处理
|
|
|
|
try{
|
|
|
|
|
|
|
|
if(interfaceRunData.req_body_type === 'raw'){
|
|
|
|
if(headers && headers['Content-Type']){
|
|
|
|
if(headers['Content-Type'].indexOf('application/x-www-form-urlencoded')>=0) {
|
|
|
|
interfaceRunData.req_body_type = 'form'
|
|
|
|
let reqData = json_parse(interfaceRunData.req_body_other);
|
|
|
|
if(reqData && typeof reqData === 'object'){
|
|
|
|
interfaceRunData.req_body_form = []
|
|
|
|
Object.keys(reqData).forEach(key=>{
|
|
|
|
interfaceRunData.req_body_form.push({
|
|
|
|
name: key,
|
|
|
|
type: 'text',
|
|
|
|
value: JSON.stringify(reqData[key]),
|
|
|
|
enable:true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if(headers['Content-Type'].indexOf('application/json')>=0) {
|
|
|
|
interfaceRunData.req_body_type = 'json'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch(e){
|
|
|
|
console.log('err',e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (HTTP_METHOD[interfaceRunData.method].request_body) {
|
|
|
|
if (interfaceRunData.req_body_type === 'form') {
|
2018-05-16 20:04:54 +08:00
|
|
|
requestBody = paramsToObjectWithEnable(
|
2018-06-13 13:59:36 +08:00
|
|
|
safeArray(interfaceRunData.req_body_form).filter(item => {
|
2018-05-16 20:04:54 +08:00
|
|
|
return item.type == 'text';
|
|
|
|
})
|
|
|
|
);
|
2018-06-13 13:59:36 +08:00
|
|
|
} else if (interfaceRunData.req_body_type === 'json') {
|
|
|
|
let reqBody = isJson5(interfaceRunData.req_body_other);
|
2017-11-29 21:52:39 +08:00
|
|
|
if (reqBody === false) {
|
2018-06-13 13:59:36 +08:00
|
|
|
requestBody = interfaceRunData.req_body_other;
|
2017-11-29 21:52:39 +08:00
|
|
|
} else {
|
|
|
|
if (requestParams) {
|
|
|
|
requestParams = Object.assign(requestParams, reqBody);
|
|
|
|
}
|
|
|
|
requestBody = handleJson(reqBody, handleValue);
|
|
|
|
}
|
2017-12-05 15:13:31 +08:00
|
|
|
} else {
|
2018-06-13 13:59:36 +08:00
|
|
|
requestBody = interfaceRunData.req_body_other;
|
2017-11-29 21:52:39 +08:00
|
|
|
}
|
2017-12-04 21:32:09 +08:00
|
|
|
requestOptions.data = requestBody;
|
2018-06-13 13:59:36 +08:00
|
|
|
if (interfaceRunData.req_body_type === 'form') {
|
2018-05-16 20:04:54 +08:00
|
|
|
requestOptions.files = paramsToObjectWithEnable(
|
2018-06-13 13:59:36 +08:00
|
|
|
safeArray(interfaceRunData.req_body_form).filter(item => {
|
2018-05-16 20:04:54 +08:00
|
|
|
return item.type == 'file';
|
|
|
|
})
|
|
|
|
);
|
2018-06-13 13:59:36 +08:00
|
|
|
} else if (interfaceRunData.req_body_type === 'file') {
|
2018-05-16 20:04:54 +08:00
|
|
|
requestOptions.file = 'single-file';
|
2017-12-04 21:32:09 +08:00
|
|
|
}
|
2017-11-29 21:52:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return requestOptions;
|
2018-02-08 16:03:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.checkRequestBodyIsRaw = checkRequestBodyIsRaw;
|
|
|
|
exports.handleParams = handleParams;
|
|
|
|
exports.handleContentType = handleContentType;
|
|
|
|
exports.crossRequest = crossRequest;
|
|
|
|
exports.handleCurrDomain = handleCurrDomain;
|
|
|
|
exports.checkNameIsExistInArray = checkNameIsExistInArray;
|