![](/img/trans.png)
[英]How to parse and save the response returned in logs for JSR223Sampler
[英]How to capture response of a Bean shell sampler
您可以使用SampleResult對象添加輸出:
String output = "...";
SampleResult.setResponseData( output );
SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );
return
關鍵字 最小的工作代碼如下,根據您的需要進行調整:
import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; URL url = new URL("http://example.com"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); String response = IOUtils.toString(con.getInputStream(), StandardCharsets.UTF_8); return response;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.