HTTP Request in Apache JMeter

This sampler serves the purpose to send a http/https request to a web server. It can also select to send or retrieve files of images or other resources.

Http Request

The figure below is an image of http request sampler:

HTTP Request Apacje Jmeter

There are different fields inside the http request panel:

Server name or IP: It is a mandatory field and it should be filled up by the server name or address ( for e.g. We also have a similar field in proxy server section. The server name should be that of the proxy server from which the request will me made.

Port: It is the port number to which the webserver is listening to. It may vary for different websites. We have a similar field for proxy server. We should add the port number for which the proxy server listens to.

Username: It should include the username required for the proxy server.

Password: It should include the password for the proxy server.

Connect timeout: It is the maximum amount of time for which the request should wait till the connection opens. It must be in milliseconds.

Response timeout: It is the maximum amount of time for which the request should wait till the response is received. It must be in milliseconds.

Implementation: The jmeter allows different HTTP protocol implementations. There are 4 implementations that are available, namely, HTTPClient3.1, HTTPClient4, blank value and java.
The HTTPClient3.1 and HTTPClient4 uses corresponding apache HttpComponents HttpClient . HTTPClient 3.1 is hardly used nowadays. The blank option does not set any implementation. It leaves it to http request defaults to decide or it looks for the implementation in the ( jmeter.httpsampler ) file.

Protocol: Its default value is http while the jmeter supports https and file apart from http.

Method: The jmeter supports the following methode GET, POST, HEAD, TRACE, OPTIONS, PUT, DELETE, PATCH. The following methods are not allowed with java implementation. The HttpClient4 allows the added support of the following methods COPY, LOCK, MKCOL, MOVE, PROPFIND, PROPPATCH, UNLOCK.

Content encoding: This is used for specific methods (POST, PUT, PATCH and FILE) and it is the character code that will be used along the methods involved.

Redirects automatically: If this check-box is clicked,  jmeter protocol handler will automatically redirects and thus these redirects will not appear as another samplers. It is used primarily with get or head method.

Follow redirects: It has only effects if ‘redirect automatically’ is not enabled. If follow redirects is enabled then the jmeter sampler will follow the redirect response . The redirects will appear as additional samples.

Use keep alive: It can be used in httpcomponents httpclient implementation only. By http keep alive, jmeter does not create a new connection for multiple jmeter requests rather it re-uses the same connection.

Use multipart/form-data for HTTP POST : It is an encoding type without which one cannot send a file with the POST method.

Browser compatible headers: When using multipart/form-data, this suppresses the Content-Type and Content-Transfer-Encoding headers; only the Content-Disposition header is sent.

Retrieve All Embedded Resources from HTML Files: It tell jmeter to send http request for all images, java applets, JavaScript , CSS etc referenced in the file.

Use concurrent pool and pool size : This is the number of concurrent connection that will extract the embed resources together. We can enable it by clicking the checkbox.

Use as a monitor: it is checked if the result are to be monitored with the monitor result listener.
Send parameters with request: if the request requires some additional data which should be dispatched along with the request then we should use this section. The data dispatched has 4 columns: name, value, encoding and include equals.

Once all these values are provided, the jmeter can create a query string based on these variables. The query string generated also depends on the method. If the method is get or delete , the query generated will be appended to the URL. If it is post or put, then the query is dispatched separately.

HTTP Request Defaults

This element can be used to set default values to threads or to controllers. For e.g. if there are multiple controllers which requests to same server or ip, then we can provide the value of server in the Http request defaults.

Note: A http request default and a http request have a similar structure. So, any request parameter can be made available to all the controllers. The http request default cannot override the samplers or controllers parameter’s value.

Http request Default