"Turn" JMeter Learning (35) Use JMeter to send json/gzip format data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.