1. Add HTTP Header Manager to test plan/thread group:
Content-Encoding: gzip
Accept-Encoding:gzip,deflate
2. Add Beanshell Preprocessor to http sampler ,script like:
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));
3. set that field: “Content Encoding” field of your HTTP request to blank.
4. 压缩请求前后对比