JMeter β HTTP Header Manager
The browser sends the server an HTTP request header along with additional information. In order to meet the needs of the server and process that particular request, additional information is needed. Whenever a browser sends a request to a server, headers containing data such as Accept-Language, Accept-Encoding, User-Agent, Recommender, and others are attached.
JMeter’s “HTTP Header Manager” element allows you to add that extra data to the request.
It is not necessary to have a different HTTP header handler for each request when writing a JMeter script unless the request specifically requests a unique header. Depending on the type of request, you can have one HTTP header handler per thread or none at all. JMeter supports multiple header managers at different levels. All inputs (fields) from the main and local HTTP header managers are combined at the sample level. The local value overrides the value of the main HTTP Header Manager field if the main and local header managers have the same header field name but different values. This makes it possible to create a standard set of headers and apply value changes at the sample level.
How to add the ‘HTTP Header Manager’ element?
You can follow the below steps to add Global Header Manager:
- Select the “Test Plan” or “Sample” node
- Right-click on the relevant node
- Mouse over ‘Add’
- Move your mouse over ‘Setting Item’
- Click ‘HTTP Header Manager’
What are the input fields of βHTTP Header Managerβ?
- Name: To provide element name
- Comments: To provide arbitrary comments (if any)
- Headers Stored in the Header Manager: List of the header fields which will be passed with the request.
β’ Accept-Language: This specifies the preferred language of the page that the browser should receive as a response. for example en-GB,en-US;q=0.8,en;q=0.6
β’ Accept-Encoding: Before sending a response to a client, the server must choose which encoding technique to use, based on the accept-encoding header. like gzip and deflate
β’ User-Agent: The User-Agent allows defining the version of the receiving page and the type of client that will be displayed correctly in the browser. Mozilla/5.0 (Windows NT 6.1; WOW64), eg (KHTML, similar to Gecko) AppleWebKit/537.36 Chrome/56.0.2924.87 Safari/537.36
β’ Sender: Identifies the page from which the specific request was sent. For example, if you refer a friend to a service (like Uber) and they sign up, they get free rides. Your code is in the referrer, which helped you.
β’ Displays the content type as the content type. application/json;charset=UTF-8 for example.
β’ Accept A type of response that a browser accepts and displays without issue. For example application/JSON, text/plain, and */*
β’ Origin: The main URL is Only secure communications supported by this option. The tag name can be something like Authorization, admin, or csrftoken.