Commit be16dfd8 authored by Medicean's avatar Medicean

(Enhance:Modulebg:Request) 发包方式支持 Multipart, 在其它配置里选择

parent 900d18fd
...@@ -10,12 +10,14 @@ ...@@ -10,12 +10,14 @@
* 添加 Shell 时 URL 默认前缀 `http://` * 添加 Shell 时 URL 默认前缀 `http://`
* 添加 Shell 时根据文件后缀选择 Shell 类型并赋予默认编码(asp 默认 GBK, 其它默认 UTF8) #109 * 添加 Shell 时根据文件后缀选择 Shell 类型并赋予默认编码(asp 默认 GBK, 其它默认 UTF8) #109
* 其它配置新增 `Multipart 发包` 功能
### Core ### Core
#### 后端模块 #### 后端模块
* 数据存储新增插件配置存储管理功能 (`shell-addPluginDataConf`, `shell-editPluginDataConf`, `shell-delPluginDataConf`, `shell-getPluginDataConf`) * 数据存储新增插件配置存储管理功能 (`shell-addPluginDataConf`, `shell-editPluginDataConf`, `shell-delPluginDataConf`, `shell-getPluginDataConf`)
* 后台发包方式支持 `Multipart`, 可在Shell其它配置里选择是否开启此功能
### Other ### Other
......
...@@ -99,7 +99,7 @@ class Request { ...@@ -99,7 +99,7 @@ class Request {
if(opts['url'].match(CONF.urlblacklist)) { if(opts['url'].match(CONF.urlblacklist)) {
return event.sender.send('request-error-' + opts['hash'], "Blacklist URL"); return event.sender.send('request-error-' + opts['hash'], "Blacklist URL");
} }
const _request = superagent.post(opts['url']); let _request = superagent.post(opts['url']);
// 设置headers // 设置headers
_request.set('User-Agent', USER_AGENT); _request.set('User-Agent', USER_AGENT);
// 自定义headers // 自定义headers
...@@ -108,6 +108,13 @@ class Request { ...@@ -108,6 +108,13 @@ class Request {
} }
// 自定义body // 自定义body
const _postData = Object.assign({}, opts.body, opts.data); const _postData = Object.assign({}, opts.body, opts.data);
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
}else{
_request.send = old_send;
}
_request _request
.proxy(APROXY_CONF['uri']) .proxy(APROXY_CONF['uri'])
.type('form') .type('form')
...@@ -158,7 +165,7 @@ class Request { ...@@ -158,7 +165,7 @@ class Request {
let indexEnd = -1; let indexEnd = -1;
let tempData = []; let tempData = [];
const _request = superagent.post(opts['url']); let _request = superagent.post(opts['url']);
// 设置headers // 设置headers
_request.set('User-Agent', USER_AGENT); _request.set('User-Agent', USER_AGENT);
// 自定义headers // 自定义headers
...@@ -167,6 +174,13 @@ class Request { ...@@ -167,6 +174,13 @@ class Request {
} }
// 自定义body // 自定义body
const _postData = Object.assign({}, opts.body, opts.data); const _postData = Object.assign({}, opts.body, opts.data);
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
}else{
_request.send = old_send;
}
_request _request
.proxy(APROXY_CONF['uri']) .proxy(APROXY_CONF['uri'])
.type('form') .type('form')
......
...@@ -244,6 +244,7 @@ class Base { ...@@ -244,6 +244,7 @@ class Base {
tag_e: opt['tag_e'], tag_e: opt['tag_e'],
encode: this.__opts__['encode'], encode: this.__opts__['encode'],
ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1, ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']), timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {}, headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {} body: (this.__opts__['httpConf'] || {})['body'] || {}
...@@ -285,6 +286,8 @@ class Base { ...@@ -285,6 +286,8 @@ class Base {
data: opt['data'], data: opt['data'],
tag_s: opt['tag_s'], tag_s: opt['tag_s'],
tag_e: opt['tag_e'], tag_e: opt['tag_e'],
ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
encode: this.__opts__['encode'] encode: this.__opts__['encode']
}); });
}) })
......
...@@ -168,6 +168,7 @@ module.exports = { ...@@ -168,6 +168,7 @@ module.exports = {
}, },
otherConf: { otherConf: {
nohttps: 'Ignore HTTPS certificate', nohttps: 'Ignore HTTPS certificate',
usemultipart: 'Use Multipart send payload',
terminalCache: "Use the terminal's cache", terminalCache: "Use the terminal's cache",
filemanagerCache: "Use the filemanager's cache", filemanagerCache: "Use the filemanager's cache",
uploadFragment: "Upload File Fragmentation Size", uploadFragment: "Upload File Fragmentation Size",
......
...@@ -169,6 +169,7 @@ module.exports = { ...@@ -169,6 +169,7 @@ module.exports = {
}, },
otherConf: { otherConf: {
nohttps: '忽略HTTPS证书', nohttps: '忽略HTTPS证书',
usemultipart: '使用 Multipart 发包',
terminalCache: '虚拟终端使用缓存', terminalCache: '虚拟终端使用缓存',
filemanagerCache: '文件管理使用缓存', filemanagerCache: '文件管理使用缓存',
uploadFragment: '上传文件分片大小', uploadFragment: '上传文件分片大小',
......
...@@ -317,6 +317,7 @@ class Form { ...@@ -317,6 +317,7 @@ class Form {
_createOtherForm(arg) { _createOtherForm(arg) {
const opt = Object.assign({}, { const opt = Object.assign({}, {
'ignore-https': 0, 'ignore-https': 0,
'use-multipart': 0,
'terminal-cache': 0, 'terminal-cache': 0,
'filemanager-cache': 1, 'filemanager-cache': 1,
'upload-fragment': '500', 'upload-fragment': '500',
...@@ -330,6 +331,9 @@ class Form { ...@@ -330,6 +331,9 @@ class Form {
{ {
type: "checkbox", name: 'ignore-https', label: LANG['list']['otherConf']['nohttps'], type: "checkbox", name: 'ignore-https', label: LANG['list']['otherConf']['nohttps'],
checked: opt['ignore-https'] === 1 checked: opt['ignore-https'] === 1
}, {
type: "checkbox", name: 'use-multipart', label: LANG['list']['otherConf']['usemultipart'],
checked: opt['use-multipart'] === 1
}, { }, {
type: "checkbox", name: 'terminal-cache', label: LANG['list']['otherConf']['terminalCache'], type: "checkbox", name: 'terminal-cache', label: LANG['list']['otherConf']['terminalCache'],
checked: opt['terminal-cache'] === 1 checked: opt['terminal-cache'] === 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment