refactor(接口测试): curl增加raw类型
This commit is contained in:
parent
95ea080fe8
commit
0d9d396fa0
|
@ -52,7 +52,8 @@ public interface CurlPatternConstants {
|
|||
/**
|
||||
* --data-raw 请求体
|
||||
*/
|
||||
Pattern HTTP_ROW_BODY_PATTERN = Pattern.compile("--data-raw '(.+?)'(?s)", Pattern.DOTALL);
|
||||
Pattern HTTP_XML_JSON_BODY_PATTERN = Pattern.compile("--data-raw '(.+?)'(?s)", Pattern.DOTALL);
|
||||
Pattern HTTP_ROW_BODY_PATTERN = Pattern.compile("--data-binary\\s+['\"](.+?)['\"](?s)", Pattern.DOTALL);
|
||||
|
||||
/**
|
||||
* --form 请求体
|
||||
|
|
|
@ -50,9 +50,15 @@ public class HttpBodyHandler extends CurlHandlerChain {
|
|||
entity.setBody(parseUrlEncodeBody(urlencodeMatcher));
|
||||
}
|
||||
|
||||
Matcher xmlJsonMatcher = CurlPatternConstants.HTTP_XML_JSON_BODY_PATTERN.matcher(curl);
|
||||
if (xmlJsonMatcher.find()) {
|
||||
entity.setBody(parseRowBody(xmlJsonMatcher, entity));
|
||||
}
|
||||
|
||||
Matcher rawMatcher = CurlPatternConstants.HTTP_ROW_BODY_PATTERN.matcher(curl);
|
||||
if (rawMatcher.find()) {
|
||||
entity.setBody(parseRowBody(rawMatcher, entity));
|
||||
entity.setBodyType(Body.BodyType.RAW.name());
|
||||
entity.setBody(rawMatcher.group(1));
|
||||
}
|
||||
|
||||
Matcher defaultMatcher = CurlPatternConstants.DEFAULT_HTTP_BODY_PATTERN.matcher(curl);
|
||||
|
|
|
@ -298,6 +298,13 @@ export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string,
|
|||
value: body as string,
|
||||
};
|
||||
break;
|
||||
case RequestBodyFormat.RAW:
|
||||
requestBody.bodyType = bodyType;
|
||||
requestBody.rawBody = {
|
||||
...cloneDeep(defaultBodyParams.rawBody),
|
||||
value: body as string,
|
||||
};
|
||||
break;
|
||||
case RequestBodyFormat.FORM_DATA:
|
||||
requestBody.bodyType = bodyType;
|
||||
requestBody.formDataBody = {
|
||||
|
|
Loading…
Reference in New Issue