refactor(项目管理): 修复自定义js代码请求api时生成的脚本没有判断响应码是否是200的问题

--bug=1014236 --user=宋天阳 【项目管理】自定义代码片段,js语言,导入接口定义,执行报错了
https://www.tapd.cn/55049933/s/1186949
This commit is contained in:
song-tianyang 2022-06-20 16:44:33 +08:00 committed by f2c-ci-robot[bot]
parent 411168eb84
commit d5b66aa54d
1 changed files with 4 additions and 1 deletions

View File

@ -398,13 +398,16 @@ conn.setRequestMethod(requestMethod);
conn.setDoOutput(true);
${connStr}conn.connect();
${postParamExecCode}
var res = "";
var rspCode = conn.getResponseCode();
if (rspCode == 200) {
var ipt = conn.getInputStream();
var reader = new java.io.BufferedReader(new java.io.InputStreamReader(ipt, "UTF-8"));
var lines;
var res = "";
while((lines = reader.readLine()) !== null) {
res += lines;
}
}
log.info(res);
`;
}