I. Using JMeter to send gzip data
Sometimes we need to impersonate the client after compressing the data, sending (POST) to the server side. Usually this happens on the mobile terminal. The benefit of doing so is that you can save traffic. Of course, the data returned by the server can also be in gzip format, and the terminal needs to be decompressed before the data is displayed. The same is to save network traffic.
1. First we put the data to post, save it in a text file, and then gzip compression. (You can use the gzip command in Linux)
2. In JMeter HTTP sample, using "Send file data at the same time", select the gzip compressed file, and the MIME type, select gzip.
3. Add an HTTP header manager and add the following header parameters.
Content-type:x-application/x-gzip
Content-encoding:gzip
4. If you need to allow the server to return content in gzip format, you need to add the HTTP header, Accept-encoding:gzip.
Second, use JMeter to send JSON format data
1. Header-manager Modify the Content-type value.
If you do not modify the value, the default is UrlEncode data format (for example, a=5&b=6).
After being modified to JSON, the server is told to send data in Application/json format. Prevents the server from forcing validation of data types.
2. Add a HTTP request request sample, so that according to the diagram instance configuration, it can easily implement the data sent in JSON format.
In fact, the Post method is used to send parameters, but the name of the parameter is empty, value is the JSON string you want to post.
PS: the JMeter HTTP Sampler (HTTP request sampler) in the newer version already has a post body tag that can be filled directly with the post body value. For example, this picture below. In fact, he and the second step in the setup content is consistent.
"Turn" JMeter Learning (35) Use JMeter to send json/gzip format data