‘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 correct method type in each HTTP Request.
- It makes JMeter script simple and easily maintainable. If 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
How to add ‘HTTP Request Defaults’?
You can follow below steps to add HTTP Request Defaults:
- Select the ‘Test Plan‘ node
- Right-click on the ‘Test Plan’ node
- Hover the mouse on ‘Add’
- Hover the mouse on ‘Config Element‘
- Click on ‘HTTP Request Defaults’
What are the input fields of ‘HTTP Request Defaults’?
‘HTTP Request Defaults’ has the following input fields:
- Name: To provide element name
- Comments: To provide arbitrary comments (if any)
- Protocol [http:]: Either http or https (Do not use ://)
- Server Name or IP: Domain name or IP address of the webserver without including prefix http://
- Port Number: Port number of Web-server. In case there is no port number then keep it blank.
- Path: It is a path to the resource. You can keep it blank for home page request or use /.
- Content Encoding: The encoding to be used for the request
- 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.
- 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.
- Connect: Number of milliseconds to wait for a connection to open.
- Response: Number of milliseconds to wait for a response
- Parallel downloads: This option enables the parallel downloading of the embedded resources. Enable this option by checkmark ‘Retrieve All Embedded Resources’ option.
- Number: Limit the number of parallel download by specifying the number. Enable this option by checkmark ‘Parallel downloads’ option.
- URLs must match: If present, this must be a regular expression that is used to match against any embedded URLs found.
- Source address: Select the IP/Address or device type and provide the appropriate input in the text box.
- Scheme: Provide the protocol type http or https
- Server Name or IP: Hostname or IP address of a proxy server without http:// to perform the request.
- Port Number: The port number of the proxy server
- Username(Optional): username for the proxy server.
- Password(Optional): password for the proxy server.
- Save response as MD5 hash?: Checkmark the option in case you want to save the response in MD5 hash format.