Pages

Monday, 30 January 2017

JMeter - Config Element - "HTTP Header Manager"

Http Request Header
The HTTP request header is sent to the server from the browser with some additional information which is required to fulfil the server requirements to respond to that particular request. Each time the browser sends a request to a server attaching the headers with information like Accept-Language, Accept-Encoding, User-Agent, Referer etc.

JMeter provides HTTP header manager element to attach that additional information along with the request. It is not necessary to have a separate HTTP header manager with each request unless request needs a unique header. You can have one HTTP header manager at Thread level or none (as per request type). JMeter now supports multiple Header Managers. The header entries are merged to form the list for the sampler. If an entry to be merged matches an existing header name, it replaces the previous entry, unless the entry value is empty, in which case any existing entry is removed. This allows one to set up a default set of headers, and apply adjustments to the particular sampler.

How to add "HTTP Header Manager" element?
You can follow below steps to add Global Header Manager:
1. Select "Test Plan" node
2. Right click on "Test Plan" node
3. Mouse hovers "Add"
4. Mouse hovers "Config Element"
5. Click "HTTP Header Manager" 

You can follow below steps to add Local Header Manager:
1. Select "Sampler" node
2. Right click on "Sampler" node
3. Mouse hovers "Add"
4. Mouse hovers "Config Element"
5. Click "HTTP Header Manager" 


How to remove "HTTP Header Manager" element?
You can follow the below steps:
1. Select "HTTP Header Manager" node
2. Right click on "HTTP Header Manager" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"  

What are the attributes of "HTTP Header Manager" element?
"HTTP Header Manager" has below attributes:
  • Name: To provide element name
  • Comments: To provide arbitrary comments (if any)
  • Tag (Name): Name of the tag. You can pass below tags in the header.
  • 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 the defining of the type of client and receiving version of the page that will be correctly displayed in 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 referer 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 which browser accept and display without any issue. e.g. application/json, text/plain, */*
  • Origin: The parent URL  

JMeter Script with local "HTTP Header Manager":


JMeter Script with global "HTTP Header Manager":



Next Topic:
Apache JMeter - "HTTP Request Defaults" Element

Previous Topic:
Apache JMeter - "HTTP Cookie Manager" Element

Related Topics:

No comments:

Post a Comment