HTTP Request Sampler in JMeter

HTTP Request Sampler in JMeter

Function Description

In JMeter, a sampler is used to simulate user requests and collect corresponding request and response data. Samplers can send various types of requests, such as HTTP requests, FTP requests, database requests, etc. They simulate user behavior by sending requests to the system under test and collecting the returned response data into the test results. Samplers are one of the most important components in a JMeter test plan, used to simulate user behavior and measure system performance and stability. The most commonly used samplers are the HTTP Request and Debug Sampler.

HTTP Request Sampler is used for testing web applications and is the most commonly used sampler for testing web services. It can send various HTTP requests, including GET, POST, PUT, DELETE, and other request methods.

HTTP Request Sampler in JMeter

Interface Description

HTTP Request Sampler in JMeter

Name: Used to identify a sampler, it is recommended to use a meaningful name.

Comment: This has no effect on the test, only for user-readable comment information.

Protocol: The protocol used when sending HTTP requests to the target server, which can be http, https, or File, with the default value being http.

Server Name or IP: The target server name or IP address to which the HTTP request is sent.

Port Number: The port number of the target server, with the default value being 80, and 443 for https.

HTTP Request: The method for sending HTTP requests, available methods include GET, POST, etc.

Path: The target URL path (excluding the server address and port).

Content Encoding: The encoding method of the content, with the default value being iso8859; generally filled in as utf-8.

Automatic Redirection: If this option is selected, when the response received after sending the HTTP request is 302/301, JMeter will automatically redirect to the new page, but JMeter does not record the content of the redirection process.

Follow Redirects: The default option for the HttpRequest sampler, which automatically jumps to the target address when the response code is 3xx. Unlike automatic redirection, JMeter records all request responses during the redirection process, and the content returned by the server can be seen in the View Results Tree. If there are multiple redirects, all requests will be recorded; this is the default option.

Use KeepAlive: When this option is selected, JMeter uses KeepAlive for HTTP communication with the target server, which is selected by default.

Use multipart/form-data for POST: When sending POST requests, use multipart/form-data or application/x-www-form-urlencoded methods, which are not selected by default.

Browser-Compatible Headers: When multipart/form-data is checked, selecting this option will strip the Content-Type and Content-Transfer-Encoding from the HTTP request headers and only send the Content-Disposition part.

Parameters: All parameters in the URL can be set in this table, with each row being a parameter value pair. It is best to set the encoding option to UTF-8 and check it to prevent parameter values from containing ASCII Control Characters or Non-ASCII characters or other symbols that may cause garbled issues.

Message Body Data: The data information sent along with the request, supporting various data formats such as json, xml, etc.

File Upload: The file information sent along with the request, with the parameter name being the corresponding parameter for the file being sent, and MINEType being the resource media type.

HTTP Request Sampler in JMeter

Implementation: The method for sending HTTP requests, with options being java and HttpClient4, defaulting to HttpClient4.

Connection: Connection timeout setting, in milliseconds.

Response: Response wait timeout setting, in milliseconds.

Get All Resources from HTML File: When this option is selected, JMeter will parse the HTML content after sending the HTTP request and obtaining the response, and retrieve all resources contained in the HTML.

Parallel Download: Set whether to use a self-defined resource pool, which can be set after checking.

Quantity: Resource pool size.

URL Must Match: URL matching filter; if this item is filled, only resources matching this content will be downloaded.

Source Address: Only used for HTTP protocol and when Implementation is HttpClient4; this property is used to enable IP spoofing. It will overwrite the default local IP address used by this HTTP request. This is used when the JMeter host has multiple IP addresses (i.e., IP aliases, network interfaces, devices).

Proxy Server: Configuration information related to the proxy server.

Save Response as MD5 Hash: If this option is selected, only the MD5 value of the server response data will be recorded during execution, without recording the complete response data.

HTTP Request Sampler in JMeter

Example

HTTP Request Sampler in JMeterHTTP Request Sampler in JMeterHTTP Request Sampler in JMeter

Leave a Comment