JMeter – HTTP Header Manager

The browser sends an HTTP request header with some additional information to the server. This additional information is required to fulfil the server requirements to respond to that particular request. Each time the browser sends a request to a server attach the headers with information like Accept-Language, Accept-Encoding, User-Agent, Referer etc.
JMeter provides an ‘HTTP Header Manager’ element to attach that additional information along with the request.

While creating the JMeter script, it is not mandatory to have a separate HTTP header manager for each request unless the request needs a unique header. You can have one HTTP header manager at the Thread level or none (as per request type). JMeter supports multiple Header Managers at different levels. At the sampler level, all the entries (fields) of the parent and local HTTP Header Manager are merged. If the parent and local header manager has the same header field name with different values then the local value replaces the parent HTTP Header Manager field value. This allows one to set up a default set of headers and apply adjustments to the value at the sampler level.

How to add the ‘HTTP Header Manager’ element?

You can follow the below steps to add Global Header Manager:

  1. Select the ‘Test Plan‘ or ‘Sampler’ node
  2. Right-click on the respective node
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘Config Element
  5. Click ‘HTTP Header Manager’
JMeter - HTTP Header Manager
Figure 01: Adding HTTP Header Manager

What are the input fields?

  • 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.
Figure 02: JMeter HTTP Header Manager

You can add below generic header fields:

  • Accept-Language : It defines the language of the page that the browser prefers to receive in the response. e.g en-GB,en-US;q=0.8,en;q=0.6
  • Accept-Encoding: The accept-encoding header tells the server which coding method the server should select before sending the response to a client. e.g. gzip, deflate
  • User-Agent: The User-Agent allows to define the type of client and receiving page version that will be correctly displayed in the browser. e.g. Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 
  • Referer: It shows that the particular request was sent while switching from a certain page. e.g. When you send a referral URL to your friend to sign-up (like Uber) and his sign-up gives you free rides. The referrer URL contains your code and benefited you.
  • Content-Type: It shows the type of content. e.g. application/json;charset=UTF-8
  • Accept: The type of response that which browser accepts and displays without any issue. e.g. application/json, text/plain, */*
  • Origin: The parent URL
  • <security check>: This option is available only for secured communication. The tag name could be cfadmin, csrftoken, Authorization etc.

You may be interested:


Leave a Comment