Send a request with header
Reference: Http://jmeter.apache.org/usermanual/build-adv-web-test-plan.html#header_manager
JMeter inside the header that manages the sent request uses the HTTP header manager. Use it to add or override various header properties, such as "User-agent", "Pragma", "Referer", and so on.
Add HTTP Header Manager method: add–> Config element–> HTTP header Manager
Can be placed directly into the thread group, so that it acts on all requests within the set of threads. It can also be placed under a request, which only acts on the current request.
After adding the test plan, you can see that the request sent has two connection, one is automatically added, and the other is the request header that was added via HTTP header manager.
Send a request with a cookie
Reference: Http://jmeter.apache.org/usermanual/build-web-test-plan.html#adding_cookie_support
Manage cookies using Cookie Manager.
The cookie Manager element automatically stores and sends cookies like a browser. If the HTTP request is included in the response, Cookie,cookie Manager will automatically store the cookie and use the value of these cookies in future access to the site. Each user has its own independent cookie store, so it does not interfere with each other. This automatically stored cookie is not visible in the cookie Manager, but can be seen in the View Result tree.
The cookie value can also be stored in the jmeter thread variable. If you want to save the cookie as a variable, you need to define the attribute "Cookiemanager.save.cookies=true" in Jmeter.properties. This assumes that the name of a cookie is TEST, and we can use ${cookie_test} to refer to it, and jmeter by default adds a prefix cookie in front of the cookie variable, or you can use the attribute " cookiemanager.name.prefix= "from the definition prefix.
If you want to add some cookies manually, you can add them directly inside the user-defined-cookies. This allows these cookies to be shared by all threads.
After you add a cookie, you can see the cookie sent in the request of View Results tree.
It is important to note that JMeter does not advocate the use of multiple cookie Manager. If more than one cookie Manager is used, JMeter cannot determine which one will be used.
IV: Building an advanced Web test plan