JMeter – HTTP Request Defaults

‘HTTP Request Defaults’ is a very basic and key element of JMeter. This config element is used when all requests in the JMeter script are sent to the same server. You can add a single HTTP Request Defaults element under Test Plan with the proper server name or IP address in the field ‘Server Name or IP’. Now, when you add HTTP Request controllers, then leave the ‘Server Name or IP’ field empty. The controllers will inherit this field value from the HTTP Request Defaults element. Make sure you have provided the correct method type in each HTTP Request.

Advantages:

  • It makes the JMeter script simple and easily maintainable. If the server name or IP changes, then you do not need to change those details in each HTTP Request. Just make changes in HTTP Request Defaults and that will be applicable for all the HTTP Requests.
  • It reduces the chances of missing the URL/port changes from HTTP Requests
  • It also avoids data duplication
JMeter - HTTP Request Defaults
Figure 01: HTTP Request Defaults

How to add ‘HTTP Request Defaults’?

You can follow the below steps to add HTTP Request Defaults:

  1. Select the ‘Test Plan‘ node
  2. Right-click on the ‘Test Plan’ node
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘Config Element
  5. Click on ‘HTTP Request Defaults’ 

What are the input fields of ‘HTTP Request Defaults’?

‘HTTP Request Defaults’ has the following input fields:

  1. Name: To provide element name
  2. Comments: To provide arbitrary comments (if any)
  3. Protocol [http:]: Either http or https (Do not use ://)
  4. Server Name or IP: Domain name or IP address of the web server without including prefix http://
  5. Port Number: Port number of Web-server. In case there is no port number then keep it blank.
  6. Path: It is a path to the resource. You can keep it blank for home page requests or use /.
  7. Content Encoding: The encoding to be used for the request
  8. Send Parameters With the Request: The query string will be generated from the list of parameters you provide. Each parameter has a name and value. The query string will be generated in the correct fashion, depending on the choice of “Method” you made.
  9. Implementation: Java, HttpClient3.1, HttpClient4. If not specified the default depends on the value of the JMeter property jmeter.httpsampler, failing that, the Java implementation is used.
  10. Connect: Number of milliseconds to wait for a connection to open.
  11. Response: Number of milliseconds to wait for a response
  12. Retrieve All Embedded Resources: Allow JMeter to parse the HTML file and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
  13. Parallel downloads: This option enables the parallel downloading of the embedded resources. Enable this option by checkmark the ‘Retrieve All Embedded Resources’ option.
  14. Number: Limit the number of parallel downloads by specifying the number. Enable this option by checkmark ‘Parallel downloads’ option.
  15. URLs must match: If present, this must be a regular expression that is used to match against any embedded URLs found.
  16. Source address: Select the IP/Address or device type and provide the appropriate input in the text box.
  17. Scheme: Provide the protocol type http or https
  18. Server Name or IP: Hostname or IP address of a proxy server without http:// to perform the request. 
  19. Port Number: The port number of the proxy server 
  20. Username(Optional): username for the proxy server.
  21. Password(Optional): password for the proxy server.
  22. Save response as MD5 hash?: Checkmark the option in case you want to save the response in MD5 hash format.

You may be interested:

Leave a Comment