# Response

> Extends Yii response handling with PSR-7 response conversion.

[API reference](/docs/api/index.md) › [PSR bridge](/docs/extensions/psr-bridge/reference/index.md) › [http](/docs/extensions/psr-bridge/reference/http/index.md) › Response

| class | `yii2\extensions\psrbridge\http\Response` |
| --- | --- |
| Extends | [`yii\web\Response`](/docs/api/yii/web/response/index.md) » [`yii\base\Response`](/docs/api/yii/base/response/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Source | [`src/http/Response.php`](https://github.com/yii2-extensions/psr-bridge/blob/main/src/http/Response.php#L19) |

Extends Yii response handling with PSR-7 response conversion.

[`ResponseAdapter`](/docs/extensions/psr-bridge/reference/adapter/responseadapter/index.md) Yii response to PSR-7 response adapter.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-acceptMimeType"></span>[`$acceptMimeType`](/docs/api/yii/web/response/index.md#property-acceptMimeType) | `string\|null` | The MIME type (e.g. `application/json`) from the request ACCEPT header chosen for this response. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-acceptParams"></span>[`$acceptParams`](/docs/api/yii/web/response/index.md#property-acceptParams) | `array` | The parameters (e.g. `['q' => 1, 'version' => '1.0']`) associated with the [chosen MIME type](/docs/api/yii/web/response/index.md#property-acceptMimeType). Default: `[]`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-charset"></span>[`$charset`](/docs/api/yii/web/response/index.md#property-charset) | `string\|null` | The charset of the text response. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-content"></span>[`$content`](/docs/api/yii/web/response/index.md#property-content) | `string\|null` | The response content. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-cookies"></span>[`$cookies`](/docs/api/yii/web/response/index.md#property-cookies) read-only | [`yii\web\CookieCollection`](/docs/api/yii/web/cookiecollection/index.md) | The cookie collection. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| [`$cookieValidationKey`](#property-cookieValidationKey) | `string` | A secret key used for cookie validation. Default: `''`. | `Response` |
| <span id="property-data"></span>[`$data`](/docs/api/yii/web/response/index.md#property-data) | `mixed` | The original response data. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-downloadHeaders"></span>[`$downloadHeaders`](/docs/api/yii/web/response/index.md#property-downloadHeaders) write-only | `string` | The attachment file name. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-enableCookieValidation"></span>`$enableCookieValidation` | `bool` | Whether to sign outgoing cookie values with [`$cookieValidationKey`](/docs/extensions/psr-bridge/reference/http/response/index.md#property-cookieValidationKey). Default: `false`. | `Response` |
| <span id="property-exitStatus"></span>[`$exitStatus`](/docs/api/yii/base/response/index.md#property-exitStatus) | `int` | The exit status. Default: `0`. | [`yii\base\Response`](/docs/api/yii/base/response/index.md) |
| <span id="property-format"></span>[`$format`](/docs/api/yii/web/response/index.md#property-format) | `string` | The response format. Default: `self::FORMAT_HTML`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-formatters"></span>[`$formatters`](/docs/api/yii/web/response/index.md#property-formatters) | `array` | The formatters for converting data into the response content of the specified [`$format`](/docs/api/yii/web/response/index.md#property-format). Default: `[]`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-headers"></span>[`$headers`](/docs/api/yii/web/response/index.md#property-headers) read-only | [`yii\web\HeaderCollection`](/docs/api/yii/web/headercollection/index.md) | The header collection. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-httpStatuses"></span>[`$httpStatuses`](/docs/api/yii/web/response/index.md#property-httpStatuses) static | `array` | List of HTTP status codes and the corresponding texts Default: `[100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 118 => 'Connection timed out', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 208 => 'Already Reported', 210 => 'Content Different', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 310 => 'Too many Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested range unsatisfiable', 417 => 'Expectation failed', 418 => 'I\'m a teapot', 421 => 'Misdirected Request', 422 => 'Unprocessable entity', 423 => 'Locked', 424 => 'Method failure', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 449 => 'Retry With', 450 => 'Blocked by Windows Parental Controls', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway or Proxy Error', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 507 => 'Insufficient storage', 508 => 'Loop Detected', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended', 511 => 'Network Authentication Required']`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isClientError"></span>[`$isClientError`](/docs/api/yii/web/response/index.md#property-isClientError) read-only | `bool` | Whether this response indicates a client error. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isEmpty"></span>[`$isEmpty`](/docs/api/yii/web/response/index.md#property-isEmpty) read-only | `bool` | Whether this response is empty. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isForbidden"></span>[`$isForbidden`](/docs/api/yii/web/response/index.md#property-isForbidden) read-only | `bool` | Whether this response indicates the current request is forbidden. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isInformational"></span>[`$isInformational`](/docs/api/yii/web/response/index.md#property-isInformational) read-only | `bool` | Whether this response is informational. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isInvalid"></span>[`$isInvalid`](/docs/api/yii/web/response/index.md#property-isInvalid) read-only | `bool` | Whether this response has a valid [`$statusCode`](/docs/api/yii/web/response/index.md#property-statusCode). | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isNotFound"></span>[`$isNotFound`](/docs/api/yii/web/response/index.md#property-isNotFound) read-only | `bool` | Whether this response indicates the currently requested resource is not found. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isOk"></span>[`$isOk`](/docs/api/yii/web/response/index.md#property-isOk) read-only | `bool` | Whether this response is OK. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isRedirection"></span>[`$isRedirection`](/docs/api/yii/web/response/index.md#property-isRedirection) read-only | `bool` | Whether this response is a redirection. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isSent"></span>[`$isSent`](/docs/api/yii/web/response/index.md#property-isSent) | `bool` | Whether the response has been sent. Default: `false`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isServerError"></span>[`$isServerError`](/docs/api/yii/web/response/index.md#property-isServerError) read-only | `bool` | Whether this response indicates a server error. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-isSuccessful"></span>[`$isSuccessful`](/docs/api/yii/web/response/index.md#property-isSuccessful) read-only | `bool` | Whether this response is successful. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-psr7Response"></span>`$psr7Response` read-only | `Psr\Http\Message\ResponseInterface` | PSR-7 ResponseInterface instance representing the current Yii Response. | `Response` |
| <span id="property-statusCode"></span>[`$statusCode`](/docs/api/yii/web/response/index.md#property-statusCode) | `int` | The HTTP status code to send with the response. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-statusCodeByException"></span>[`$statusCodeByException`](/docs/api/yii/web/response/index.md#property-statusCodeByException) write-only | [`Throwable`](https://www.php.net/manual/en/class.throwable.php) | The exception object. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-statusText"></span>[`$statusText`](/docs/api/yii/web/response/index.md#property-statusText) | `string` | The HTTP status description that comes together with the status code. Default: `'OK'`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-stream"></span>[`$stream`](/docs/api/yii/web/response/index.md#property-stream) | `resource\|array\|callable\|null` | The stream to be sent. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="property-version"></span>[`$version`](/docs/api/yii/web/response/index.md#property-version) | `string\|null` | The version of the HTTP protocol to use. Default: `null`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`captureSessionCookie()`](#method-captureSessionCookie) | Queues the current session ID, including rotation followed by an explicit close. | `Response` |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-clear"></span>[`clear()`](/docs/api/yii/web/response/index.md#method-clear) | Clears the headers, cookies, content, status code of the response. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-clearOutputBuffers"></span>[`clearOutputBuffers()`](/docs/api/yii/base/response/index.md#method-clearOutputBuffers) | Removes all existing output buffers. | [`yii\base\Response`](/docs/api/yii/base/response/index.md) |
| [`completeSend()`](#method-completeSend) | Completes the Yii response send lifecycle after the runtime emits the PSR-7 body. | `Response` |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getCookies"></span>[`getCookies()`](/docs/api/yii/web/response/index.md#method-getCookies) | Returns the cookie collection. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getHeaders"></span>[`getHeaders()`](/docs/api/yii/web/response/index.md#method-getHeaders) | Returns the header collection. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsClientError"></span>[`getIsClientError()`](/docs/api/yii/web/response/index.md#method-getIsClientError) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsEmpty"></span>[`getIsEmpty()`](/docs/api/yii/web/response/index.md#method-getIsEmpty) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsForbidden"></span>[`getIsForbidden()`](/docs/api/yii/web/response/index.md#method-getIsForbidden) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsInformational"></span>[`getIsInformational()`](/docs/api/yii/web/response/index.md#method-getIsInformational) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsInvalid"></span>[`getIsInvalid()`](/docs/api/yii/web/response/index.md#method-getIsInvalid) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsNotFound"></span>[`getIsNotFound()`](/docs/api/yii/web/response/index.md#method-getIsNotFound) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsOk"></span>[`getIsOk()`](/docs/api/yii/web/response/index.md#method-getIsOk) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsRedirection"></span>[`getIsRedirection()`](/docs/api/yii/web/response/index.md#method-getIsRedirection) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsServerError"></span>[`getIsServerError()`](/docs/api/yii/web/response/index.md#method-getIsServerError) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getIsSuccessful"></span>[`getIsSuccessful()`](/docs/api/yii/web/response/index.md#method-getIsSuccessful) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| [`getPsr7Response()`](#method-getPsr7Response) | Converts the Yii Response component to a PSR-7 ResponseInterface instance. | `Response` |
| <span id="method-getStatusCode"></span>[`getStatusCode()`](/docs/api/yii/web/response/index.md#method-getStatusCode) |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/web/response/index.md#method-init) | Initializes this component. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-redirect"></span>[`redirect()`](/docs/api/yii/web/response/index.md#method-redirect) | Redirects the browser to the specified URL. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-refresh"></span>[`refresh()`](/docs/api/yii/web/response/index.md#method-refresh) | Refreshes the current page. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-send"></span>[`send()`](/docs/api/yii/web/response/index.md#method-send) | Sends the response to the client. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendContentAsFile"></span>[`sendContentAsFile()`](/docs/api/yii/web/response/index.md#method-sendContentAsFile) | Sends the specified content as a file to the browser. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendFile"></span>[`sendFile()`](/docs/api/yii/web/response/index.md#method-sendFile) | Sends a file to the browser. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendStreamAsFile"></span>[`sendStreamAsFile()`](/docs/api/yii/web/response/index.md#method-sendStreamAsFile) | Sends the specified stream as a file to the browser. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-setDownloadHeaders"></span>[`setDownloadHeaders()`](/docs/api/yii/web/response/index.md#method-setDownloadHeaders) | Sets a default set of HTTP headers for file downloading purpose. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-setStatusCode"></span>[`setStatusCode()`](/docs/api/yii/web/response/index.md#method-setStatusCode) | Sets the response status code. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-setStatusCodeByException"></span>[`setStatusCodeByException()`](/docs/api/yii/web/response/index.md#method-setStatusCodeByException) | Sets the response status code based on the exception. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-xSendFile"></span>[`xSendFile()`](/docs/api/yii/web/response/index.md#method-xSendFile) | Sends existing file to a browser as a download using x-sendfile. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-defaultFormatters"></span>[`defaultFormatters()`](/docs/api/yii/web/response/index.md#method-defaultFormatters) protected |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getDispositionHeaderValue"></span>[`getDispositionHeaderValue()`](/docs/api/yii/web/response/index.md#method-getDispositionHeaderValue) protected | Returns Content-Disposition header value that is safe to use with both old and new browsers. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-getHttpRange"></span>[`getHttpRange()`](/docs/api/yii/web/response/index.md#method-getHttpRange) protected | Determines the HTTP range given in the request. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-prepare"></span>[`prepare()`](/docs/api/yii/web/response/index.md#method-prepare) protected | Prepares for sending the response. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendContent"></span>[`sendContent()`](/docs/api/yii/web/response/index.md#method-sendContent) protected | Sends the response content to the client. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendCookies"></span>[`sendCookies()`](/docs/api/yii/web/response/index.md#method-sendCookies) protected | Sends the cookies to the client. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="method-sendHeaders"></span>[`sendHeaders()`](/docs/api/yii/web/response/index.md#method-sendHeaders) protected | Sends the response headers to the client. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |

## Events

| Event | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="event-EVENT_BEFORE_SEND"></span>[`EVENT_BEFORE_SEND`](/docs/api/yii/web/response/index.md#event-EVENT_BEFORE_SEND) | [`yii\base\Event`](/docs/api/yii/base/event/index.md) | An event that is triggered at the beginning of [`send()`](/docs/api/yii/web/response/index.md#method-send). Event name: `'beforeSend'`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="event-EVENT_AFTER_SEND"></span>[`EVENT_AFTER_SEND`](/docs/api/yii/web/response/index.md#event-EVENT_AFTER_SEND) | [`yii\base\Event`](/docs/api/yii/base/event/index.md) | An event that is triggered at the end of [`send()`](/docs/api/yii/web/response/index.md#method-send). Event name: `'afterSend'`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="event-EVENT_AFTER_PREPARE"></span>[`EVENT_AFTER_PREPARE`](/docs/api/yii/web/response/index.md#event-EVENT_AFTER_PREPARE) | [`yii\base\Event`](/docs/api/yii/base/event/index.md) | An event that is triggered right after [`prepare()`](/docs/api/yii/web/response/index.md#method-prepare) is called in [`send()`](/docs/api/yii/web/response/index.md#method-send). Event name: `'afterPrepare'`. | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-FORMAT_RAW"></span>[`FORMAT_RAW`](/docs/api/yii/web/response/index.md#const-FORMAT_RAW) | `'raw'` |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="const-FORMAT_HTML"></span>[`FORMAT_HTML`](/docs/api/yii/web/response/index.md#const-FORMAT_HTML) | `'html'` |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="const-FORMAT_JSON"></span>[`FORMAT_JSON`](/docs/api/yii/web/response/index.md#const-FORMAT_JSON) | `'json'` |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="const-FORMAT_JSONP"></span>[`FORMAT_JSONP`](/docs/api/yii/web/response/index.md#const-FORMAT_JSONP) | `'jsonp'` |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |
| <span id="const-FORMAT_XML"></span>[`FORMAT_XML`](/docs/api/yii/web/response/index.md#const-FORMAT_XML) | `'xml'` |  | [`yii\web\Response`](/docs/api/yii/web/response/index.md) |

## Property details

### $cookieValidationKey <span id="property-cookieValidationKey"></span>

```php
public string $cookieValidationKey = ''
```

A secret key used for cookie validation.

Set this property when [`$enableCookieValidation`](/docs/extensions/psr-bridge/reference/http/response/index.md#property-enableCookieValidation) is `true`.

## Method details

### captureSessionCookie() <span id="method-captureSessionCookie"></span>

```php
public function captureSessionCookie(): void
```

Queues the current session ID, including rotation followed by an explicit close.

### completeSend() <span id="method-completeSend"></span>

```php
public function completeSend(): void
```

Completes the Yii response send lifecycle after the runtime emits the PSR-7 body.

Triggers [`EVENT_AFTER_SEND`](/docs/api/yii/web/response/index.md#event-EVENT_AFTER_SEND) and marks the response as sent, running the back half of [`send()`](/docs/api/yii/web/response/index.md#method-send) that
[`getPsr7Response()`](/docs/extensions/psr-bridge/reference/http/response/index.md#method-getPsr7Response) intentionally defers. Returns immediately when the response is already sent.

Call this after the PSR-7 response has been emitted so lazy body streams (such as [`sendFile()`](/docs/api/yii/web/response/index.md#method-sendFile) or
[`sendStreamAsFile()`](/docs/api/yii/web/response/index.md#method-sendStreamAsFile)) are consumed before after-send handlers run.

### getPsr7Response() <span id="method-getPsr7Response"></span>

```php
public function getPsr7Response(): Psr\Http\Message\ResponseInterface
```

Converts the Yii Response component to a PSR-7 ResponseInterface instance.

Triggers before-send and after-prepare, closes an active session after queuing its cookie, and delegates
conversion to [`ResponseAdapter`](/docs/extensions/psr-bridge/reference/adapter/responseadapter/index.md). Does not emit bytes, trigger after-send, or mark the response sent.
Use [`Application::finalize()`](/docs/extensions/psr-bridge/reference/http/application/index.md#method-finalize) after emission for application-managed responses; for standalone use,
call [`completeSend()`](/docs/extensions/psr-bridge/reference/http/response/index.md#method-completeSend) after successful emission.

**Returns**

`Psr\Http\Message\ResponseInterface`: PSR-7 ResponseInterface instance representing the current Yii Response.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the configuration is invalid or incomplete.
- [`yii\di\NotInstantiableException`](/docs/api/yii/di/notinstantiableexception/index.md): if a class or service can't be instantiated.