将HTTP标头管理器添加到您的测试计划,并至少添加以下标头:
- 内容类型:application / json
- 内容编码:gzip
- 将Beanshell PreProcessor添加为您需要编码的请求的子代,并将以下代码添加到其“脚本”区域:
import org.apache.commons.io.IOUtils; import java.util.zip.GZIPOutputStream; String bodyString = sampler.getArguments().getArgument(0).getValue(); byte [] requestBody = bodyString.getBytes(); ByteArrayOutputStream out = new ByteArrayOutputStream(requestBody.length); GZIPOutputStream gzip = new GZIPOutputStream(out); gzip.write(requestBody); gzip.close(); sampler.getArguments().getArgument(0).setValue(out.toString(0));
它将获取您的请求主体,对其进行压缩并即时替换,以便将请求压缩。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)