Commit 354eed16 authored by Medicean's avatar Medicean

(Enhance:Module:Request) 增加Chunked传输支持

parent 03c6d6f4
This diff is collapsed.
......@@ -245,6 +245,9 @@ class Base {
tag_e: opt['tag_e'],
encode: this.__opts__['encode'],
ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1,
useChunk: (this.__opts__['otherConf'] || {})['use-chunk'] === 1,
chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2,
chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {},
......
......@@ -169,6 +169,13 @@ module.exports = {
otherConf: {
nohttps: 'Ignore HTTPS certificate',
usemultipart: 'Use Multipart send payload',
chunk: {
title: 'Chunked Transfer (Experimentally)',
usechunk: 'Use Chunked send payload.',
min: 'Min Block',
max: 'Max Block',
exphint: 'This feature is currently experimental and cannot be used with Multipart. Some types of servers may not support Chunked transfers. In addition, it is recommended to set the timeout period to 30s or more to avoid data transmission when the network speed is not good.',
},
terminalCache: "Use the terminal's cache",
filemanagerCache: "Use the filemanager's cache",
uploadFragment: "Upload File Fragmentation Size",
......
......@@ -170,6 +170,13 @@ module.exports = {
otherConf: {
nohttps: '忽略HTTPS证书',
usemultipart: '使用 Multipart 发包',
chunk: {
title: '分块传输(实验性功能)',
usechunk: '开启分块传输发包',
min: '最小分块',
max: '最大分块',
exphint: '该功能目前为实验性功能, 无法与 Multipart 同时使用,部分类型的服务端可能不支持Chunked传输。此外,建议超时时长设置30s以上,避免网速不好的情况下影响数据传输。',
},
terminalCache: '虚拟终端使用缓存',
filemanagerCache: '文件管理使用缓存',
uploadFragment: '上传文件分片大小',
......
......@@ -318,6 +318,9 @@ class Form {
const opt = Object.assign({}, {
'ignore-https': 0,
'use-multipart': 0,
'use-chunk': 0,
'chunk-step-byte-min': 2,
'chunk-step-byte-max': 3,
'terminal-cache': 0,
'filemanager-cache': 1,
'upload-fragment': '500',
......@@ -334,7 +337,60 @@ class Form {
}, {
type: "checkbox", name: 'use-multipart', label: LANG['list']['otherConf']['usemultipart'],
checked: opt['use-multipart'] === 1
}, {
}, { type: 'fieldset', offsetLeft: 0, label: LANG['list']['otherConf']['chunk']['title'], list: [
{ type: 'block', offsetLeft: 0, list: [
{
type: "checkbox", name: 'use-chunk', label: LANG['list']['otherConf']['chunk']['usechunk'], checked: opt['use-chunk'] === 1
},
]},
{ type: 'block', offsetLeft: 0, list: [
{ type:'label', label: LANG['list']['otherConf']['chunk']['min']},
{ type:'newcolumn' },
{
type: 'combo', label: '/byte', validate: 'ValidNumeric', inputWidth: 50, name: "chunk-step-byte-min",
options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['chunk-step-byte-min']) === -1) {
items.unshift(opt['chunk-step-byte-min']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['chunk-step-byte-min'] === _
})
});
return ret;
})([
'2', '4', '10', '50', '100', '500'
])
},
{ type:'newcolumn',},
{ type:'label', label: LANG['list']['otherConf']['chunk']['max'], offsetLeft: 30,},
{ type:'newcolumn' },
{
type: 'combo', label: '/byte', validate: 'ValidNumeric', inputWidth: 50, name: "chunk-step-byte-max",
options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['chunk-step-byte-max']) === -1) {
items.unshift(opt['chunk-step-byte-max']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['chunk-step-byte-max'] === _
})
});
return ret;
})([
'2', '4', '10', '50', '100', '500'
])
},
]},
]}, {
type: "checkbox", name: 'terminal-cache', label: LANG['list']['otherConf']['terminalCache'],
checked: opt['terminal-cache'] === 1
}, {
......@@ -405,6 +461,28 @@ class Form {
])
}
]}], true);
form.attachEvent('onChange', (name, value, state)=>{
switch(name){
case 'use-multipart':
if(state == true && form.isItemChecked('use-chunk')) {
form.uncheckItem('use-chunk');
}
break;
case 'use-chunk':
if(state == true && form.isItemChecked('use-multipart')) {
form.uncheckItem('use-multipart');
}
if(state == true) {
layer.open({
title: LANG_T['info']
,content: LANG['list']['otherConf']['chunk']['exphint']
});
}
break;
default:
break;
}
});
return form;
}
......
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