> For the complete documentation index, see [llms.txt](https://security.navidnaf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://security.navidnaf.com/aragoogs-nest/http-s/response.md).

# Response

An HTTP response is the data that a web server sends back to the client after responding to an HTTP request. It contains information about the processing of the request, such as the request status, metadata in headers, and often a body that includes the requested content or an error message.

When you interact with a web application, the server responds with an HTTP message indicating whether your request was successful or if there was an issue. The response includes a **status code**, which is a three-digit number, and a **reason phrase**, which provides a brief description of the result.

## **Status Line Structure**

The first line of every HTTP response, known as the **status line**, consists of:

* **HTTP Version**: Specifies which HTTP version is being used.
* **Status Code**: A three-digit number indicating the outcome of the request.
* **Reason Phrase**: A short, human-readable message explaining the status code.

```
[HTTP/VERSION] [STATUS CODE] [REASON PHRASE]
```

## **Response Headers**

In HTTP, response headers provide metadata about the server's response. These headers contain important information such as the type of content being sent, the server's identity, and caching directives. They help the client process the response and understand what to expect in the body.

Below are some essential response headers –

| Response Header | Description                                                 | Example                              |
| --------------- | ----------------------------------------------------------- | ------------------------------------ |
| Content-Type    | Specifies the media type of the response body.              | text/html; charset=UTF-8             |
| Content-Length  | Indicates the size of the response body in bytes.           | 1024                                 |
| Date            | The date and time when the response was sent.               | Wed, 08 Dec 2024 12:00:00 GMT        |
| Server          | Identifies the software used by the server.                 | Apache/2.4.41 (Ubuntu)               |
| Cache-Control   | Specifies the caching behavior of the response.             | no-cache, no-store                   |
| Location        | Used in redirection to specify the new URL of the resource. | <https://navidnaf.com/new-page>      |
| Expires         | Indicates when the response should be considered outdated.  | Thu, 09 Dec 2024 12:00:00 GMT        |
| Set-Cookie      | Sends a cookie from the server to the client.               | session\_id=abc123; Path=/; HttpOnly |
| ETag            | Provides a unique identifier for a version of the resource. | "1234567890"                         |
| X-Powered-By    | Specifies the technology used by the server.                | PHP/7.4.3                            |

## **Response Body**

The response body contains the main content of an HTTP response. In a successful request, the body typically includes the requested resource (such as HTML content, JSON data, or images). In an error response, the body may contain an error message or description. Responses like **204 No Content**, or cases where no additional data is required, usually have an empty body. The format and structure of the body are determined by the **Content-Type** specified in the response headers.
