> OctoPerf load testing - HTTP Action documentation page. HTTP Actions are used to send HTTP and HTTPS request to the server during a performance test.

Source: https://api.octoperf.com/doc/design/edit-virtual-user/action-types/http-actions/

# HTTP Actions

The HTTP Action lets you **send an HTTP/HTTPS request to a web server**. There are height types of HTTP request actions. One for [each HTTP method](http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods).

![HTTP Request Action](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-request-action.png "HTTP Request Action")


The HTTP Action is composed of many sections in order to configure:
<div class="grid cards" markdown>

- [:fontawesome-solid-passport: Base Settings](#base-settings)

- [:fontawesome-solid-globe: Query Parameters](#query-parameters)

- [:fontawesome-solid-heading: Request Headers](#request-headers)

- [:material-align-vertical-distribute: Request Body](#request-body)

- [:fontawesome-solid-bug: Debug](#debug)

</div>

## Base Settings

### Base URL

The request URL usually looks like this: `http://petstore.octoperf.com:80/actions/Catalog.action?viewProduct&productId=K9-DL-01`.

This URL is divided in 3 parts:

1. The [server](#server) `http://petstore.octoperf.com:80`.
2. The [path](#path) `/actions/Catalog.action`.
3. The parameters `?viewProduct&productId=K9-DL-01` are configured in the [Query Parameters](#query-parameters) tab.

#### Server

![HTTP Request server](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-server.png "HTTP Request server")

The request server can be selected using the server combo box. All servers are configured in the [servers](https://api.octoperf.com/doc/design/edit-virtual-user/configuration/servers/) view but it is possible to create a new one with the **Add Server** button.

<div style="clear:both"></div>

#### Path

The path lets you type the address of  the resource to call on the server (here `/actions/Catalog.action`).

!!! info
    The initial **/** will be automatically added if you omit it.


### Settings

![Http Action Configuration](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-action-configuration.png "Http Action Configuration")

| Option                 | Description                                                  |
| ---------------------- | ------------------------------------------------------------ |
| **Name**               | Override the HTTP request default name (otherwise the default name is the request path). |
| **Follow redirects**   | If this option is selected, OctoPerf checks if the response is a redirect (status code 3xx) and follows it. |
| **Content Encoding**   | Content encoding to be used (for POST, PUT, PATCH and FILE). This is the character encoding to be used, and is not related to the Content-Encoding HTTP header. Default value (if left empty) is **UTF-8**. |
| **Download Resources** | Enables the automatic download of resources, more details below. |

#### Download Resources

If this option is selected, OctoPerf parses the HTML file received and sends HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.

!!! Note
    If the request has a **HOST** header it will be used when fetching the resources as well.
    When the resources have a different domain, this can generate 404 responses.
    To prevent this, remove the **HOST** header from the main request.

During runtime, **only a single aggregated value for all Resources will be displayed**. But when you run a [validation](https://api.octoperf.com/doc/design/edit-virtual-user/validation/) they will all be displayed with the label **Sub result** in the [Debug panel](#debug):

![sub-samples](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/sub-samples.png)

In the above screenshot, the difference between the label **Validation** and the first sub result **Catalog.action** is in the timings. If you only check the request/response contents, you'll notice they are identical, that's because:

- **Validation** contains the time between the main request was sent and the last resource was downloaded (depending on [parallel downloads](#parallel-downloads-number)),
- **Catalog.action** contains the time for this particular HTTP request only.

![timings-sub-samples](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/timings-sub-samples.png)

!!! Warning
    This option consumes a lot of computing power, to compensate for that we will consider the virtual users as [Heavy VUs](https://api.octoperf.com/doc/on-premise-agent/providers/#memory-usage).

##### Parallel Downloads Number

Modern browsers use ~6 parallel threads for downloading embedded resources. Adjust the value up or down to mimic browser(s) you would like to simulate.

##### URLs Must Match

If present, this must be a regular expression that is used to match against any embedded URLs found. You can use it to:

- Allow a single domain: `http://example\.com/.*`,
- Forbid a list of domains: `^((?!<domain #1>|<domain #2>|<domain #3><domain #4>|<domain #5>).)*$`

### Think Time

The think time is a pause that simulates the time a real user spends between two actions, for example reading a page. The virtual user pauses **before** sending the HTTP request, once the previous request has completed.

When you create a Virtual User from a HAR file, think times are computed from the recorded timestamps. Refer to the [HAR import think times](https://api.octoperf.com/doc/design/create-virtual-user/har-recorder/#think-times) for details.

As they serve to represent user interaction delay, Think times are not taken into account when computing server response times.

!!! warning
    If a think time is higher than the remaining duration for the test, the virtual user will be stopped automatically. This mechanism is used to free memory but it will be visible on the `# of Users` statistics of the report. To avoid this it is recommended to use small values in regards to the test duration (for example: less than 1 min for a 1 hour test)

![Constant Delay](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/think-time.png "Constant Delay")

| Type         | Description |
| --------------| --- |
| **Constant** | Constant waiting time. Unit can be selected (milliseconds, seconds, minutes or hours). |
| **Range**    | Random waiting time between two boundaries. Unit can be selected. |
| **Text**     | Constant waiting time, can be a variable name. Always in milliseconds. |

A new HTTP action has a constant think time of 1 second. To change the think times of many requests at once, use the [search and replace](https://api.octoperf.com/doc/design/edit-virtual-user/search-and-replace/). To replace all of them for a test, use the [user profile policies](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/policies/#think-time).

## Query Parameters

The Query Parameters section shows a table that contains one row for each query parameter. For instance with the parameters `?viewCategory&categoryId=DOGS`:

![URL Parameters](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/url-parameters.png "URL Parameters")

| Column name                         | Description |
|-------------------------------------| --- |
| **Name**                            | The name of the query parameter. |
| **=**                               | Select this option to include an '=' after the parameter name. Mandatory when the parameter has a value. |
| **Value**                           | The value of the query parameter. |
| **Encode**                          | Should this query parameter name and value be encoded. [URL encoding](http://en.wikipedia.org/wiki/Percent-encoding) replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. Uncheck it when the value is already encoded, or it is encoded twice: see [Parameter already URL-encoded](https://api.octoperf.com/doc/design/edit-virtual-user/validation/#already-url-encoded). |
| ![add-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/add-line.png){ .off-glb }       | Click this icon to add a new parameter at the end of the list. |
| ![remove-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/remove-line.png){ .off-glb } | Click this icon to remove a parameter. Be careful, this action cannot be undone. |

!!! Info
    The search functions are detailed in [this section of the navigation page](https://api.octoperf.com/doc/navigation/#filters).

## Request Headers

![HTTP Headers](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-headers.png "HTTP Headers")

The HTTP Headers section is a table with one row for each request header. [HTTP headers](http://en.wikipedia.org/wiki/List_of_HTTP_header_fields) lets you define, among many other things:

* The expected content type,
* The content length,
* The authorization,
* The accepted charset, encoding and language,
* ...

!!! info
    The **Cookie** header is automatically handled by the platform. You do not need to extract or inject it.
    

    The **User-Agent** is overwritten when the Virtual User is running. The configuration of the User Agent is done in the [user profile settings](https://api.octoperf.com/doc/runtime/edit-scenario/edit-user-profile/options/device/#user-agent).

| Column name                             | Description                                                                   |
| --------------------------------------- |-------------------------------------------------------------------------------|
| **Name**                                | The name of the header.                                                       |
| **Value**                               | The value of the header.                                                      |
| ![add-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/add-line.png){ .off-glb }           | Click this icon to add a new header at the end of the list.                   |
| ![remove-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/remove-line.png){ .off-glb }     | Click this icon to remove a header. Be careful, this action cannot be undone. |
| ![header-picker](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/header-picker.png){ .off-glb } | Select a header name from the **most used headers** list.                     |

!!! Info
    The search functions are detailed in [this section of the navigation page](https://api.octoperf.com/doc/navigation/#filters).

## Request Body

The request body, or POST data, exists in 5 types:

* [Multipart](#form-data): The content type `multipart/form-data` should be used for submitting forms that contain files, non-ASCII data, or binary data. With `multipart/form-data` no characters are encoded. This value is required when you are using forms that have a file upload control.
* [Urlencoded](#urlencoded): The content type `application/x-www-form-urlencoded` is inefficient for sending large quantities of binary data or text containing non-ASCII characters. Using `application/x-www-form-urlencoded` all characters are encoded before being sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values).
* [Raw](#raw) text requests: For `text/plain` spaces are converted to "+" symbols, but no special characters are encoded.
* [File](#file): Particular use case of `application/x-www-form-urlencoded` that focuses on uploading a single file,
* None: When this request doesn't have a body at all (GET requests for example).

!!! tip
    Duplicate the request before playing with the request body settings. When you switch between body types the body is emptied. 

### Form-data

![Form data](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-form-data.png "Form data")

The `multipart/form-data` content-type is used by web browsers if the form contains the `enctype="multipart/form-data"` attribute.

| Column name                         | Description                                                                                                    |
| ----------------------------------- |----------------------------------------------------------------------------------------------------------------|
| **Type**                            | **Text** or **File**                                                                                           |
| **Name**                            | The name of the POST parameter.                                                                                |
| **Value**                           | The value of the POST parameter.                                                                               |
| **Content Type**                    | [Mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the embedded file. |
| ![add-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/add-line.png){ .off-glb }       | Click this icon to add a new parameter at the end of the list.                                                 |
| ![remove-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/remove-line.png){ .off-glb } | Click this icon to remove a parameter. Be careful, this action cannot be undone.                               |

!!! Info
    The search functions are detailed in [this section of the navigation page](https://api.octoperf.com/doc/navigation/#filters).

In some situations, it is required to only send the `Content-Disposition header`, that is possible through the **Browser-compatible headers** option, here's a comparison using the above example:

=== "Regular headers"

    ![Regular headers](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/form-data-regular-headers.png "Regular headers")

=== "Browser-compatible headers"

    ![Browser compatible headers](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/form-data-browser-compatible-headers.png "Browser compatible headers")

### Urlencoded

![Form urlencoded](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-form-urlencoded.png "Form urlencoded")

| Column name                         | Description                                                                                                                                                                                         |
| ----------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Name**                            | The name of the POST parameter.                                                                                                                                                                     |
| **=**                               | Select this option to include an '=' after the parameter name.Mandatory when the parameter has a value.                                                                                             |
| **Value**                           | The value of the POST parameter.                                                                                                                                                                    |
| **Encode**                          | Should this POST parameter name and value be encoded. [URL encoding](http://en.wikipedia.org/wiki/Percent-encoding) replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. Uncheck it when the value is already encoded, or it is encoded twice: see [Parameter already URL-encoded](https://api.octoperf.com/doc/design/edit-virtual-user/validation/#already-url-encoded). |
| ![add-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/add-line.png){ .off-glb }       | Click this icon to add a new parameter at the end of the list.                                                                                                                                      |
| ![remove-line](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/remove-line.png){ .off-glb } | Click this icon to remove a parameter. Be careful, this action cannot be undone.                                                                                                                    |

!!! Info
    The search functions are detailed in [this section of the navigation page](https://api.octoperf.com/doc/navigation/#filters).

When a web browser sends a POST request from a web form element, the default media type is *application/x-www-form-urlencoded*. For these requests, OctoPerf automatically adds the appropriate Content-Type header and converts the parameters.
*application/x-www-form-urlencoded* is a format for encoding key-value pairs with possibly duplicate keys. Each key-value pair is separated by an '&' character, and each key is separated from its value by an '=' character.
Keys and values are both escaped by replacing spaces with the '+' character and then using URL encoding on all other non-alphanumeric characters.

For example, the key-value pairs

* Name: Jonathan Doe
* Age: 23
* Formula: a + b == 13%!

are encoded as `Name=Jonathan+Doe&Age=23&Formula=a+%2B+b+%3D%3D+13%25%21`

### raw

![Raw](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-raw.png "Raw")

The raw POST only contains a text input. 

You can simply type or paste the content of your request payload. 

Variables are allowed inside the payload as for any other POST parameter.

![http-post-raw-format](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-raw-format.png){ align=right }

You can change the format of the raw POST data by using the ![http-post-raw-format-button](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-raw-format-button.png){ .off-glb } button. The request `Content-Type` header is automatically modified according to this format. And you can use the **Format content** option to make the raw content easier to read.

!!! info
    Setting the right formatting is not mandatory. If you don't plan on using it, just make sure that your payload is valid and manually add the proper headers.

<div style="clear:both"></div>

!!! warning
    For performance reasons, raw bodies of more than 20 Mb cannot be saved through OctoPerf's UI. In that case, you need to use a [file](#file) instead. Note that files are usually limited to 100 Mb on the SaaS platform.

### file

![File](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/http-post-file.png "File")

The **file** option lets you add one single file to your request body. 

With this option the content of the file is copied directly into a the POST body. It is possible to achieve the same through a [raw body](#raw) if you copy/paste your file in it but that will inflate the size of your virtual user and can impact its performance.

| Column name      | Description                                                                                                     |
| ---------------- |-----------------------------------------------------------------------------------------------------------------|
| **Name**         | The name of the file as specified in the [files menu](https://api.octoperf.com/doc/design/edit-virtual-user/configuration/files/).                         |
| **Content Type** | [Mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the embedded file . |

!!! warning
    Some HAR recorders will not save the file into the request body. Because of this we cannot detect that it is a file upload and you will have to manually [upload the file](https://api.octoperf.com/doc/design/edit-virtual-user/configuration/files/) and activate this option. 

## Debug

![debug](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug.png)

In order to validate your configuration we recommend to:

- Replay your HTTP requests with the [VU validation panel](https://api.octoperf.com/doc/design/edit-virtual-user/validation/),
- Then you can debug the content of your requests and responses in the [Debug panel](#debug),
- Once you've reached a satisfactory result, you can proceed to a [real test](https://api.octoperf.com/doc/runtime/).

![debug-occurrences](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-occurrences.png){ align=right }

The debug panel allows you to view the requests and responses played during the [record](https://api.octoperf.com/doc/design/#create-virtual-user) of the Virtual User and during a [Validate VU](https://api.octoperf.com/doc/design/edit-virtual-user/validation/).

You can use the **LEFT** and **RIGHT** drop down lists to select an occurrence. When a different occurrence is selected in each of these lists, the Debug panel will switch to [Comparison mode](#comparison-mode).

To revert back to the [Detailed mode](#detailed-mode), just select the same occurrence in both **FIRST** and **SECOND** lists.

<div style="clear:both"></div>

!!! tip
    If you create a Virtual User by hand (without importing a HAR), recorded requests and responses are not present. You may run a [validation](https://api.octoperf.com/doc/design/edit-virtual-user/validation/) to get requests / responses.

| Icon                                    | Action            | Description                                                                                         |
| --------------------------------------- | ----------------- |-----------------------------------------------------------------------------------------------------|
| ![debug-save](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-save.png){ .off-glb }       | Save as recorded  | This action will overwrite the recorded response with the new one. Be careful, it cannot be undone. |
| ![debug-new-tab](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-new-tab.png){ .off-glb } | Open in a new tab | Sends the response content in a new browser tab to attempt rendering it.                            |

### Debug Request

![debug-request](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-request.png)

![debug-request-select](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-request-select.png){ align=left }

You can click on the left Request section to access the Debug Request section. It displays:

* [Request timings](#timings),
* [Request headers](#detailed-mode),
* [Request bodies](#detailed-mode).

<div style="clear:both"></div>

### Debug Response

![debug-response](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-response.png)

![debug-response-select](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-response-select.png){ align=left }

You can click on the left Request section to access the Debug Request section. It displays:

* [Response headers](#detailed-mode),
* [Response bodies](#detailed-mode).

<div style="clear:both"></div>

### Timings

![debug-timings](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-timings.png)

In this section you can see various metrics regarding the requests. Hover your mouse on one of the bars to see the nature of this metric.

The various metrics are:

- Response times split in [Connect time/Latency/Elapsed time](https://api.octoperf.com/doc/analysis/tips/#latency-and-connect-time),
- Request size,
- Response size split in Response Headers size and response body size

!!! warning
    The recorded shows timings from your browser, they can be very different from timings of the validations executed from our cloud agents.

### Detailed mode

When only one occurrence is available or, the same occurrence is selected in both **FIRST** and **SECOND** drop down lists, the detailed mode is activated.

![debug-detailed-mode](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-detailed-mode.png)

On top of this, you can use the top right menu to perform actions:

| Icon                                | Action                     | Description                                              |
| ----------------------------------- | -------------------------- |----------------------------------------------------------|
| ![auto-format](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/auto-format.png){ .off-glb } | Enable/Disable auto format | Toggle the content formatting for this box.              |
| ![expand](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/expand.png){ .off-glb }           | Expand in new window       | Opens a new window, giving you more space to work with.  |

!!! tip
    You can use the same shortcuts as in code blocks. Check the [dedicated page](https://api.octoperf.com/doc/design/edit-virtual-user/code-editor/) for more info.

### Comparison mode

When a different occurrence is selected in **FIRST** and **SECOND** drop down lists, the debug panel switches to comparison mode. In that mode the text editor is slightly less powerful but instead you can use it to compare Headers or bodies across different occurrences.

![debug-compare-mode](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/debug-compare-mode.png)

| Icon                                   | Action                         | Description                                             |
| -------------------------------------- | ------------------------------ | ------------------------------------------------------- |
| ![debug-unlock](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/previous-next.png){ .off-glb } | Go to Previous/Next difference | Move through detected differences.                      |
| ![auto-format](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/auto-format.png){ .off-glb }    | Enable/Disable auto format     | Toggle the content formatting for this box.             |
| ![auto-format](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/compare-mode.png){ .off-glb }   | Switch comparison mode         | Toggle between side by side and in line comparison.     |
| ![expand](https://api.octoperf.com/doc/design/edit-virtual-user/action-types/img/expand.png){ .off-glb }              | Expand in new window           | Opens a new window, giving you more space to work with. |

!!! tip
    You can use the same shortcuts as in code blocks. Check the [dedicated page](https://api.octoperf.com/doc/design/edit-virtual-user/code-editor/) for more info.
