[Reserved] JMeter learning (thirty-five) to send json / gzip format data using jmeter

A, using gzip data transmitted jmeter

Sometimes we need to simulate in the client data compression, send (post) to the server. This usually will occur on the mobile terminal. The advantage of this is you can save traffic. Of course, the server returns data also can be gzip format, the terminal at the time of data presentation, we need to decompress. the same also in order to save the network traffic.

1. First of all we want to post the data is stored in a text file, then gzip compression. (You can use the linux command gzip)

2. http sample jmeter's, use "at the same time send the file data", select the file after gzip compression, and mime type, select gzip.

3. Add a http header manager, and add the following header parameters.

content-type:x-application/x-gzip

content-encoding:gzip

4. If the need to allow the server returns the content gzip format, you need to add the http header, accept-encoding: gzip.

 

Second, the use json format data transmitted jmeter

1. header-manager modified content-type value.

If the value is not modified, the default will be urlencode data format (e.g., a = 5 & b = 6).

Modified after json, will tell the server, the data sent to application / json format data. Prevent the server from doing compulsory check on the data type.

header-json

2. Add a request Sample http request, it is configured such example according to FIG., It can easily achieve data transmission json format.

In fact, the way to send post or use of parameters, just the name parameter is null, value is the value you want to post a json string.

post json

ps: newer version of http sampler jmeter (http request sampler) has a post body tag, you can fill out the post body such as the following value to this chart in fact, he and the second step of setting. content is the same. 

ce270b1d-ff53-37cb-be72-47c0c82950a5

Guess you like

Origin www.cnblogs.com/xxxs/p/11763172.html