fix(接口定义): 增加encode设置
This commit is contained in:
parent
79d235b0b9
commit
cb50a966a8
|
@ -662,10 +662,20 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
stringBuffer.append(path);
|
||||
stringBuffer.append("/");
|
||||
Map<String, String> keyValueMap = new HashMap<>();
|
||||
this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).filter(KeyValue::valueIsNotEmpty).forEach(keyValue ->
|
||||
keyValueMap.put(keyValue.getName(), keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
|
||||
ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue())
|
||||
);
|
||||
List<KeyValue> list = this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid)
|
||||
.filter(KeyValue::valueIsNotEmpty).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list.forEach(keyValue -> {
|
||||
try {
|
||||
String value = keyValue.getValue() != null && keyValue.getValue().startsWith("@") ?
|
||||
ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
|
||||
value = keyValue.isUrlEncode() ? URLEncoder.encode(value, "utf-8") : value;
|
||||
keyValueMap.put(keyValue.getName(), value);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
try {
|
||||
Pattern p = Pattern.compile("(\\{)([\\w]+)(\\})");
|
||||
Matcher m = p.matcher(path);
|
||||
|
@ -688,8 +698,13 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
this.getArguments().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue -> {
|
||||
stringBuffer.append(keyValue.getName());
|
||||
if (keyValue.getValue() != null) {
|
||||
stringBuffer.append("=").append(keyValue.getValue().startsWith("@") ?
|
||||
ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue());
|
||||
try {
|
||||
String value = keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
|
||||
value = keyValue.isUrlEncode() ? URLEncoder.encode(value, "utf-8") : value;
|
||||
stringBuffer.append("=").append(value);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
stringBuffer.append("&");
|
||||
});
|
||||
|
@ -703,7 +718,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (keyValue.getValue() == null) {
|
||||
httpArgument.setValue("");
|
||||
}
|
||||
httpArgument.setAlwaysEncoded(keyValue.isEncode());
|
||||
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
|
||||
if (StringUtils.isNotBlank(keyValue.getContentType())) {
|
||||
httpArgument.setContentType(keyValue.getContentType());
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class Body {
|
|||
KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
|
||||
sampler.setPostBodyRaw(true);
|
||||
keyValue.setEnable(true);
|
||||
keyValue.setEncode(false);
|
||||
keyValue.setUrlEncode(false);
|
||||
body.add(keyValue);
|
||||
}
|
||||
return body;
|
||||
|
|
|
@ -16,7 +16,7 @@ public class KeyValue {
|
|||
private String description;
|
||||
private String contentType;
|
||||
private boolean enable = true;
|
||||
private boolean encode = true;
|
||||
private boolean urlEncode;
|
||||
private boolean required;
|
||||
private Integer min;
|
||||
private Integer max;
|
||||
|
|
|
@ -1,23 +1,35 @@
|
|||
<template>
|
||||
<ms-edit-dialog
|
||||
:visible.sync="visible"
|
||||
width="30%"
|
||||
width="700px"
|
||||
:title="$t('run_mode.other_config')"
|
||||
:with-footer="false"
|
||||
:append-to-body="appendToBody"
|
||||
:close-on-click-modal="true">
|
||||
<el-form>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('schema.minLength')">
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="$t('schema.minLength')">
|
||||
<el-input-number :min="0" v-model="data.min" :placeholder="$t('schema.minLength')" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="$t('schema.maxLength')">
|
||||
<el-input-number :min="0" v-model="data.max" :placeholder="$t('schema.maxLength')" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="编码">
|
||||
<el-select v-model="data.urlEncode" size="small" clearable style="width: 50%;">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</ms-edit-dialog>
|
||||
|
@ -25,32 +37,40 @@
|
|||
|
||||
<script>
|
||||
|
||||
import MsEditDialog from "@/business/components/common/components/MsEditDialog";
|
||||
export default {
|
||||
name: "ApiVariableSetting",
|
||||
components: {MsEditDialog},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
data: {}
|
||||
}
|
||||
},
|
||||
props:{
|
||||
appendToBody: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
open(item) {
|
||||
this.visible = true;
|
||||
this.data = item;
|
||||
}
|
||||
}
|
||||
import MsEditDialog from "@/business/components/common/components/MsEditDialog";
|
||||
|
||||
export default {
|
||||
name: "ApiVariableSetting",
|
||||
components: {MsEditDialog},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
data: {},
|
||||
options: [{
|
||||
value: true,
|
||||
label: '是'
|
||||
}, {
|
||||
value: false,
|
||||
label: '否'
|
||||
}],
|
||||
}
|
||||
},
|
||||
props: {
|
||||
appendToBody: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
open(item) {
|
||||
this.visible = true;
|
||||
this.data = item;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
Loading…
Reference in New Issue