优化jmeter工具类
This commit is contained in:
@@ -419,15 +419,14 @@ public class JMeterUtil {
|
|||||||
if (responseDataList.getLength() > 0) {
|
if (responseDataList.getLength() > 0) {
|
||||||
Element responseDataElement = (Element) responseDataList.item(0);
|
Element responseDataElement = (Element) responseDataList.item(0);
|
||||||
resultMap.put("responseBody", responseDataElement.getTextContent());
|
resultMap.put("responseBody", responseDataElement.getTextContent());
|
||||||
return resultMap;
|
|
||||||
}
|
}
|
||||||
// 提取子节点<responseHeader>的内容
|
// 提取子节点<responseHeader>的内容
|
||||||
NodeList responseHeaderList = httpSampleElement.getElementsByTagName("responseHeader");
|
NodeList responseHeaderList = httpSampleElement.getElementsByTagName("responseHeader");
|
||||||
if (responseHeaderList.getLength() > 0) {
|
if (responseHeaderList.getLength() > 0) {
|
||||||
Element responseHeaderElement = (Element) responseHeaderList.item(0);
|
Element responseHeaderElement = (Element) responseHeaderList.item(0);
|
||||||
resultMap.put("responseHeader", responseHeaderElement.getTextContent());
|
resultMap.put("responseHeader", responseHeaderElement.getTextContent());
|
||||||
return resultMap;
|
|
||||||
}
|
}
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -442,6 +441,9 @@ public class JMeterUtil {
|
|||||||
*/
|
*/
|
||||||
public static Map<String, String> parseHeaders(String responseHeader) {
|
public static Map<String, String> parseHeaders(String responseHeader) {
|
||||||
Map<String, String> headerMap = new HashMap<>();
|
Map<String, String> headerMap = new HashMap<>();
|
||||||
|
if (responseHeader == null) {
|
||||||
|
return headerMap;
|
||||||
|
}
|
||||||
// 按行拆分
|
// 按行拆分
|
||||||
String[] lines = responseHeader.split("\n");
|
String[] lines = responseHeader.split("\n");
|
||||||
// 遍历每一行
|
// 遍历每一行
|
||||||
|
|||||||
Reference in New Issue
Block a user