# Request

> The web Request class represents an HTTP request.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › Request

| class | `yii\web\Request` |
| --- | --- |
| Extends | [`yii\base\Request`](/docs/api/yii/base/request/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) |
| Since | 2.0 |
| Source | [`framework/web/Request.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/Request.php#L92) |

2 subclasses:

- [`yii2\extensions\psrbridge\http\Request`](/docs/extensions/psr-bridge/reference/http/request/index.md)
- [`yii\inertia\web\Request`](/docs/extensions/inertia/reference/web/request/index.md)

The web Request class represents an HTTP request.

It encapsulates the $_SERVER variable and resolves its inconsistency among different Web servers.
Also it provides an interface to retrieve request parameters from $_POST, $_GET, $_COOKIES and REST
parameters sent via other HTTP methods like PUT or DELETE.

Request is configured as an application component in [`Application`](/docs/api/yii/web/application/index.md) by default.
You can access that instance via `Yii::$app->request`.

For more details and usage information on Request, see the [guide article on requests](/docs/guide/runtime-requests/index.md).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-absoluteUrl"></span>`$absoluteUrl` read-only | `string` | The currently requested absolute URL. | `Request` |
| [`$acceptableContentTypes`](#property-acceptableContentTypes) | `array` | The content types ordered by the quality score. | `Request` |
| [`$acceptableLanguages`](#property-acceptableLanguages) | `array` | The languages ordered by the preference level. | `Request` |
| <span id="property-authCredentials"></span>`$authCredentials` read-only | `array` | That contains exactly two elements: - 0: the username sent via HTTP authentication, `null` if the username is not given - 1: the password sent via HTTP authentication, `null` if the password is not given. | `Request` |
| <span id="property-authPassword"></span>`$authPassword` read-only | `string\|null` | The password sent via HTTP authentication, `null` if the password is not given. | `Request` |
| <span id="property-authUser"></span>`$authUser` read-only | `string\|null` | The username sent via HTTP authentication, `null` if the username is not given. | `Request` |
| <span id="property-baseUrl"></span>`$baseUrl` | `string` | The relative URL for the application. | `Request` |
| <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-bodyParams"></span>`$bodyParams` | `mixed` | The request parameters given in the request body. | `Request` |
| [`$contentType`](#property-contentType) read-only | `string` | Request content-type. | `Request` |
| <span id="property-cookies"></span>`$cookies` read-only | [`CookieCollection`](/docs/api/yii/web/cookiecollection/index.md) | The cookie collection. | `Request` |
| [`$cookieValidationKey`](#property-cookieValidationKey) | `string` | A secret key used for cookie validation. Default: `null`. | `Request` |
| [`$csrfCookie`](#property-csrfCookie) | `array` | The configuration for creating the CSRF [cookie](/docs/api/yii/web/cookie/index.md). Default: `['httpOnly' => true]`. | `Request` |
| [`$csrfHeader`](#property-csrfHeader) | `string` | The name of the HTTP header for sending CSRF token. Default: `self::CSRF_HEADER`. | `Request` |
| <span id="property-csrfHeaderUnsafeMethods"></span>`$csrfHeaderUnsafeMethods` | `array` | "unsafe" methods not triggered a CORS-preflight request This property is used only when both [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) and [`$validateCsrfHeaderOnly`](/docs/api/yii/web/request/index.md#property-validateCsrfHeaderOnly) are true. Default: `['GET', 'HEAD', 'POST']`. | `Request` |
| [`$csrfParam`](#property-csrfParam) | `string` | The name of the token used to prevent CSRF. Default: `'_csrf'`. | `Request` |
| [`$csrfToken`](#property-csrfToken) read-only | `null\|string` | The token used to perform CSRF validation. | `Request` |
| [`$csrfTokenFromHeader`](#property-csrfTokenFromHeader) read-only | `string\|null` | The CSRF token sent via [`$csrfHeader`](/docs/api/yii/web/request/index.md#property-csrfHeader) by browser. | `Request` |
| <span id="property-csrfTokenSafeMethods"></span>`$csrfTokenSafeMethods` | `array` | The name of the HTTP header for sending CSRF token. by default validate CSRF token on non-"safe" methods only This property is used only when [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) is true. Default: `['GET', 'HEAD', 'OPTIONS']`. | `Request` |
| [`$enableCookieValidation`](#property-enableCookieValidation) | `bool` | Whether cookies should be validated to ensure they are not tampered. Default: `true`. | `Request` |
| [`$enableCsrfCookie`](#property-enableCsrfCookie) | `bool` | Whether to use cookie to persist CSRF token. Default: `true`. | `Request` |
| [`$enableCsrfValidation`](#property-enableCsrfValidation) | `bool` | Whether to enable CSRF (Cross-Site Request Forgery) validation. Default: `true`. | `Request` |
| <span id="property-eTags"></span>`$eTags` read-only | `array` | The entity tags. | `Request` |
| <span id="property-headers"></span>`$headers` read-only | [`HeaderCollection`](/docs/api/yii/web/headercollection/index.md) | The header collection. | `Request` |
| <span id="property-hostInfo"></span>`$hostInfo` | `string\|null` | Schema and hostname part (with port number if needed) of the request URL (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set. | `Request` |
| <span id="property-hostName"></span>`$hostName` read-only | `string\|null` | Hostname part of the request URL (e.g. `www.yiiframework.com`). | `Request` |
| [`$ipHeaders`](#property-ipHeaders) | `string[]` | List of headers where proxies store the real client IP. Default: `['X-Forwarded-For']`. Available since 2.0.13. | `Request` |
| <span id="property-isAjax"></span>`$isAjax` read-only | `bool` | Whether this is an AJAX (XMLHttpRequest) request. | `Request` |
| <span id="property-isConsoleRequest"></span>[`$isConsoleRequest`](/docs/api/yii/base/request/index.md#property-isConsoleRequest) | `bool` | The value indicating whether the current request is made via console. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| <span id="property-isDelete"></span>`$isDelete` read-only | `bool` | Whether this is a DELETE request. | `Request` |
| <span id="property-isFlash"></span>`$isFlash` read-only | `bool` | Whether this is an Adobe Flash or Adobe Flex request. | `Request` |
| <span id="property-isGet"></span>`$isGet` read-only | `bool` | Whether this is a GET request. | `Request` |
| <span id="property-isHead"></span>`$isHead` read-only | `bool` | Whether this is a HEAD request. | `Request` |
| <span id="property-isOptions"></span>`$isOptions` read-only | `bool` | Whether this is a OPTIONS request. | `Request` |
| <span id="property-isPatch"></span>`$isPatch` read-only | `bool` | Whether this is a PATCH request. | `Request` |
| <span id="property-isPjax"></span>`$isPjax` read-only | `bool` | Whether this is a PJAX request. | `Request` |
| <span id="property-isPost"></span>`$isPost` read-only | `bool` | Whether this is a POST request. | `Request` |
| <span id="property-isPut"></span>`$isPut` read-only | `bool` | Whether this is a PUT request. | `Request` |
| <span id="property-isSecureConnection"></span>`$isSecureConnection` read-only | `bool` | If the request is sent via secure channel (https). | `Request` |
| [`$method`](#property-method) read-only | `string` | Request method, such as GET, POST, HEAD, PUT, PATCH, DELETE. | `Request` |
| [`$methodParam`](#property-methodParam) | `string` | The name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST. Default: `'_method'`. | `Request` |
| <span id="property-origin"></span>`$origin` read-only | `string\|null` | URL origin of a CORS request, `null` if not available. | `Request` |
| [`$parsers`](#property-parsers) | `array` | The parsers for converting the raw HTTP request body into [`$bodyParams`](/docs/api/yii/web/request/index.md#property-bodyParams). Default: `[]`. | `Request` |
| [`$pathInfo`](#property-pathInfo) | `string` | Part of the request URL that is after the entry script and before the question mark. | `Request` |
| <span id="property-port"></span>`$port` | `int` | Port number for insecure requests. | `Request` |
| [`$portHeaders`](#property-portHeaders) | `string[]` | List of headers where proxies store the real request port. Default: `['X-Forwarded-Port']`. Available since 2.0.46. | `Request` |
| <span id="property-preferredLanguage"></span>`$preferredLanguage` read-only | `string` | The language that the application should use. | `Request` |
| <span id="property-queryParams"></span>`$queryParams` | `array` | The request GET parameter values. | `Request` |
| <span id="property-queryString"></span>`$queryString` read-only | `string` | Part of the request URL that is after the question mark. | `Request` |
| <span id="property-rawBody"></span>`$rawBody` | `string` | The request body. | `Request` |
| <span id="property-referrer"></span>`$referrer` read-only | `string\|null` | URL referrer, null if not available. | `Request` |
| <span id="property-remoteHost"></span>`$remoteHost` read-only | `string\|null` | Remote host name, `null` if not available. | `Request` |
| <span id="property-remoteIP"></span>`$remoteIP` read-only | `string\|null` | Remote IP address, `null` if not available. | `Request` |
| <span id="property-scriptFile"></span>`$scriptFile` | `string` | The entry script file path. | `Request` |
| <span id="property-scriptUrl"></span>`$scriptUrl` | `string` | The relative URL of the entry script. | `Request` |
| [`$secureHeaders`](#property-secureHeaders) | `array` | Lists of headers that are, by default, subject to the trusted host configuration. Default: `['X-Forwarded-For', 'X-Forwarded-Host', 'X-Forwarded-Proto', 'X-Forwarded-Port', 'Front-End-Https', 'X-Rewrite-Url', 'X-Original-Host']`. Available since 2.0.13. | `Request` |
| <span id="property-securePort"></span>`$securePort` | `int` | Port number for secure requests. | `Request` |
| [`$secureProtocolHeaders`](#property-secureProtocolHeaders) | `array` | List of headers to check for determining whether the connection is made via HTTPS. Default: `['X-Forwarded-Proto' => ['https'], 'Front-End-Https' => ['on']]`. Available since 2.0.13. | `Request` |
| <span id="property-serverName"></span>`$serverName` read-only | `string\|null` | Server name, null if not available. | `Request` |
| <span id="property-serverPort"></span>`$serverPort` read-only | `int\|null` | Server port number, null if not available. | `Request` |
| [`$trustedHosts`](#property-trustedHosts) | `array` | The configuration for trusted security related headers. Default: `[]`. Available since 2.0.13. | `Request` |
| [`$url`](#property-url) | `string` | The currently requested relative URL. | `Request` |
| <span id="property-userAgent"></span>`$userAgent` read-only | `string\|null` | User agent, null if not available. | `Request` |
| <span id="property-userHost"></span>`$userHost` read-only | `string\|null` | User host name, null if not available. | `Request` |
| <span id="property-userIP"></span>`$userIP` read-only | `string\|null` | User IP address, null if not available. | `Request` |
| [`$validateCsrfHeaderOnly`](#property-validateCsrfHeaderOnly) | `bool` | Whether to use custom header only to CSRF validation of SPA. Default: `false`. | `Request` |

## 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) |
| <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-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) |
| [`get()`](#method-get) | Returns GET parameter with a given name. If name isn't specified, returns an array of all GET parameters. | `Request` |
| [`getAbsoluteUrl()`](#method-getAbsoluteUrl) | Returns the currently requested absolute URL. | `Request` |
| [`getAcceptableContentTypes()`](#method-getAcceptableContentTypes) | Returns the content types acceptable by the end user. | `Request` |
| [`getAcceptableLanguages()`](#method-getAcceptableLanguages) | Returns the languages acceptable by the end user. | `Request` |
| [`getAuthCredentials()`](#method-getAuthCredentials) |  | `Request` |
| [`getAuthPassword()`](#method-getAuthPassword) |  | `Request` |
| [`getAuthUser()`](#method-getAuthUser) |  | `Request` |
| [`getBaseUrl()`](#method-getBaseUrl) | Returns the relative URL for the application. | `Request` |
| <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) |
| [`getBodyParam()`](#method-getBodyParam) | Returns the named request body parameter value. | `Request` |
| [`getBodyParams()`](#method-getBodyParams) | Returns the request parameters given in the request body. | `Request` |
| [`getContentType()`](#method-getContentType) | Returns request content-type The Content-Type header field indicates the MIME type of the data contained in [`getRawBody()`](/docs/api/yii/web/request/index.md#method-getRawBody) or, in the case of the HEAD method, the media type that would have been sent had the request been a GET. | `Request` |
| [`getCookies()`](#method-getCookies) | Returns the cookie collection. | `Request` |
| [`getCsrfToken()`](#method-getCsrfToken) | Returns the token used to perform CSRF validation. | `Request` |
| [`getCsrfTokenFromHeader()`](#method-getCsrfTokenFromHeader) |  | `Request` |
| [`getETags()`](#method-getETags) | Gets the Etags. | `Request` |
| [`getHeaders()`](#method-getHeaders) | Returns the header collection. | `Request` |
| [`getHostInfo()`](#method-getHostInfo) | Returns the schema and host part of the current request URL. | `Request` |
| [`getHostName()`](#method-getHostName) | Returns the host part of the current request URL. | `Request` |
| [`getIsAjax()`](#method-getIsAjax) | Returns whether this is an AJAX (XMLHttpRequest) request. | `Request` |
| <span id="method-getIsConsoleRequest"></span>[`getIsConsoleRequest()`](/docs/api/yii/base/request/index.md#method-getIsConsoleRequest) | Returns a value indicating whether the current request is made via command line. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| [`getIsDelete()`](#method-getIsDelete) | Returns whether this is a DELETE request. | `Request` |
| [`getIsFlash()`](#method-getIsFlash) | Returns whether this is an Adobe Flash or Flex request. | `Request` |
| [`getIsGet()`](#method-getIsGet) | Returns whether this is a GET request. | `Request` |
| [`getIsHead()`](#method-getIsHead) | Returns whether this is a HEAD request. | `Request` |
| [`getIsOptions()`](#method-getIsOptions) | Returns whether this is an OPTIONS request. | `Request` |
| [`getIsPatch()`](#method-getIsPatch) | Returns whether this is a PATCH request. | `Request` |
| [`getIsPjax()`](#method-getIsPjax) | Returns whether this is a PJAX request. | `Request` |
| [`getIsPost()`](#method-getIsPost) | Returns whether this is a POST request. | `Request` |
| [`getIsPut()`](#method-getIsPut) | Returns whether this is a PUT request. | `Request` |
| [`getIsSecureConnection()`](#method-getIsSecureConnection) | Return if the request is sent via secure channel (https). | `Request` |
| [`getMethod()`](#method-getMethod) | Returns the method of the current request (e.g. GET, POST, HEAD, PUT, PATCH, DELETE). | `Request` |
| [`getOrigin()`](#method-getOrigin) | Returns the URL origin of a CORS request. | `Request` |
| [`getPathInfo()`](#method-getPathInfo) | Returns the path info of the currently requested URL. | `Request` |
| [`getPort()`](#method-getPort) | Returns the port to use for insecure requests. | `Request` |
| [`getPreferredLanguage()`](#method-getPreferredLanguage) | Returns the user-preferred language that should be used by this application. | `Request` |
| [`getQueryParam()`](#method-getQueryParam) | Returns the named GET parameter value. | `Request` |
| [`getQueryParams()`](#method-getQueryParams) | Returns the request parameters given in the [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString). | `Request` |
| [`getQueryString()`](#method-getQueryString) | Returns part of the request URL that is after the question mark. | `Request` |
| [`getRawBody()`](#method-getRawBody) | Returns the raw HTTP request body. | `Request` |
| [`getReferrer()`](#method-getReferrer) | Returns the URL referrer. | `Request` |
| [`getRemoteHost()`](#method-getRemoteHost) | Returns the host name of the other end of this connection. | `Request` |
| [`getRemoteIP()`](#method-getRemoteIP) | Returns the IP on the other end of this connection. | `Request` |
| [`getScriptFile()`](#method-getScriptFile) | Returns the entry script file path. | `Request` |
| [`getScriptUrl()`](#method-getScriptUrl) | Returns the relative URL of the entry script. | `Request` |
| [`getSecurePort()`](#method-getSecurePort) | Returns the port to use for secure requests. | `Request` |
| [`getServerName()`](#method-getServerName) | Returns the server name. | `Request` |
| [`getServerPort()`](#method-getServerPort) | Returns the server port number. If a port is specified via a forwarding header (e.g. 'X-Forwarded-Port') and the remote host is a "trusted host" the that port will be used (see [`$portHeaders`](/docs/api/yii/web/request/index.md#property-portHeaders)), otherwise the default server port will be returned. | `Request` |
| [`getUrl()`](#method-getUrl) | Returns the currently requested relative URL. | `Request` |
| [`getUserAgent()`](#method-getUserAgent) | Returns the user agent. | `Request` |
| [`getUserHost()`](#method-getUserHost) | Returns the user host name. | `Request` |
| [`getUserIP()`](#method-getUserIP) | Returns the user IP address. | `Request` |
| <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/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/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) |
| [`parseAcceptHeader()`](#method-parseAcceptHeader) | Parses the given `Accept` (or `Accept-Language`) header. | `Request` |
| [`post()`](#method-post) | Returns POST parameter with a given name. If name isn't specified, returns an array of all POST parameters. | `Request` |
| [`resolve()`](#method-resolve) | Resolves the current request into a route and the associated parameters. | `Request` |
| [`setAcceptableContentTypes()`](#method-setAcceptableContentTypes) | Sets the acceptable content types. | `Request` |
| [`setAcceptableLanguages()`](#method-setAcceptableLanguages) |  | `Request` |
| [`setBaseUrl()`](#method-setBaseUrl) | Sets the relative URL for the application. | `Request` |
| [`setBodyParams()`](#method-setBodyParams) | Sets the request body parameters. | `Request` |
| [`setHostInfo()`](#method-setHostInfo) | Sets the schema and host part of the application URL. | `Request` |
| <span id="method-setIsConsoleRequest"></span>[`setIsConsoleRequest()`](/docs/api/yii/base/request/index.md#method-setIsConsoleRequest) | Sets the value indicating whether the current request is made via command line. | [`yii\base\Request`](/docs/api/yii/base/request/index.md) |
| [`setPathInfo()`](#method-setPathInfo) | Sets the path info of the current request. | `Request` |
| [`setPort()`](#method-setPort) | Sets the port to use for insecure requests. | `Request` |
| [`setQueryParams()`](#method-setQueryParams) | Sets the request [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString) parameters. | `Request` |
| [`setRawBody()`](#method-setRawBody) | Sets the raw HTTP request body, this method is mainly used by test scripts to simulate raw HTTP requests. | `Request` |
| [`setScriptFile()`](#method-setScriptFile) | Sets the entry script file path. | `Request` |
| [`setScriptUrl()`](#method-setScriptUrl) | Sets the relative URL for the application entry script. | `Request` |
| [`setSecurePort()`](#method-setSecurePort) | Sets the port to use for secure requests. | `Request` |
| [`setUrl()`](#method-setUrl) | Sets the currently requested relative URL. | `Request` |
| <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) |
| [`validateCsrfToken()`](#method-validateCsrfToken) | Performs the CSRF validation. | `Request` |
| [`createCsrfCookie()`](#method-createCsrfCookie) protected | Creates a cookie with a randomly generated CSRF token. | `Request` |
| [`filterHeaders()`](#method-filterHeaders) protected | Filters headers according to the [`$trustedHosts`](/docs/api/yii/web/request/index.md#property-trustedHosts). | `Request` |
| [`generateCsrfToken()`](#method-generateCsrfToken) protected | Generates an unmasked random token used to perform CSRF validation. | `Request` |
| [`getIpValidator()`](#method-getIpValidator) protected | Creates instance of [`IpValidator`](/docs/api/yii/validators/ipvalidator/index.md). | `Request` |
| [`getSecureForwardedHeaderParts()`](#method-getSecureForwardedHeaderParts) protected | Returns decoded forwarded header | `Request` |
| [`getSecureForwardedHeaderTrustedPart()`](#method-getSecureForwardedHeaderTrustedPart) protected | Gets first `Forwarded` header value for token | `Request` |
| [`getSecureForwardedHeaderTrustedParts()`](#method-getSecureForwardedHeaderTrustedParts) protected | Gets only trusted `Forwarded` header parts | `Request` |
| [`getTrustedHeaders()`](#method-getTrustedHeaders) protected | Trusted headers according to the [`$trustedHosts`](/docs/api/yii/web/request/index.md#property-trustedHosts). | `Request` |
| [`getUserIpFromIpHeader()`](#method-getUserIpFromIpHeader) protected | Return user IP's from IP header. | `Request` |
| [`getUserIpFromIpHeaders()`](#method-getUserIpFromIpHeaders) protected | Returns the user IP address from [`$ipHeaders`](/docs/api/yii/web/request/index.md#property-ipHeaders). | `Request` |
| [`loadCookies()`](#method-loadCookies) protected | Converts `$_COOKIE` into an array of [`Cookie`](/docs/api/yii/web/cookie/index.md). | `Request` |
| [`loadCsrfToken()`](#method-loadCsrfToken) protected | Loads the CSRF token from cookie or session. | `Request` |
| [`resolvePathInfo()`](#method-resolvePathInfo) protected | Resolves the path info part of the currently requested URL. | `Request` |
| [`resolveRequestUri()`](#method-resolveRequestUri) protected | Resolves the request URI portion for the currently requested URL. | `Request` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-CSRF_HEADER"></span>`CSRF_HEADER` | `'X-CSRF-Token'` | Default name of the HTTP header for sending CSRF token. | `Request` |

## Property details

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

```php
public array $acceptableContentTypes
```

The content types ordered by the quality score.

Types with the
highest scores will be returned first. The array keys are the content types, while the array values are the
corresponding quality score and other parameters as given in the header.

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

```php
public array $acceptableLanguages
```

The languages ordered by the preference level.

The first element
represents the most preferred language.

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

```php
public string $contentType
```

Request content-type.

Empty string is returned if this information is
not available.

**Access**

Read-only (virtual property).

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

```php
public string $cookieValidationKey = null
```

A secret key used for cookie validation.

This property must be set if [`$enableCookieValidation`](/docs/api/yii/web/request/index.md#property-enableCookieValidation) is true.

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

```php
public array $csrfCookie = ['httpOnly' => true]
```

The configuration for creating the CSRF [cookie](/docs/api/yii/web/cookie/index.md).

This property is used only when
both [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) and [`$enableCsrfCookie`](/docs/api/yii/web/request/index.md#property-enableCsrfCookie) are true.

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

```php
public string $csrfHeader = self::CSRF_HEADER
```

The name of the HTTP header for sending CSRF token.

Defaults to [`CSRF_HEADER`](/docs/api/yii/web/request/index.md#const-CSRF_HEADER).
This property may be changed for Yii API applications only.
Don't change this property for Yii Web application.

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

```php
public string $csrfParam = '_csrf'
```

The name of the token used to prevent CSRF.

Defaults to '_csrf'.
This property is used only when [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) is true.

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

```php
public null|string $csrfToken
```

The token used to perform CSRF validation.

Null is returned if the
[`$validateCsrfHeaderOnly`](/docs/api/yii/web/request/index.md#property-validateCsrfHeaderOnly) is true.

**Access**

Read-only (virtual property).

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

```php
public string|null $csrfTokenFromHeader
```

The CSRF token sent via [`$csrfHeader`](/docs/api/yii/web/request/index.md#property-csrfHeader) by browser.

Null is
returned if no such header is sent.

**Access**

Read-only (virtual property).

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

```php
public bool $enableCookieValidation = true
```

Whether cookies should be validated to ensure they are not tampered.

Defaults to true.

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

```php
public bool $enableCsrfCookie = true
```

Whether to use cookie to persist CSRF token.

If false, CSRF token will be stored
in session under the name of [`$csrfParam`](/docs/api/yii/web/request/index.md#property-csrfParam). Note that while storing CSRF tokens in session increases
security, it requires starting a session for every page, which will degrade your site performance.

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

```php
public bool $enableCsrfValidation = true
```

Whether to enable CSRF (Cross-Site Request Forgery) validation.

Defaults to true.
When CSRF validation is enabled, forms submitted to an Yii Web application must be originated
from the same application. If not, a 400 HTTP exception will be raised.

Note, this feature requires that the user client accepts cookie. Also, to use this feature,
forms submitted via POST method must contain a hidden input whose name is specified by [`$csrfParam`](/docs/api/yii/web/request/index.md#property-csrfParam).
You may use [`Html::beginForm()`](/docs/api/yii/helpers/basehtml/index.md#method-beginForm) to generate his hidden input.

In JavaScript, you may get the values of [`$csrfParam`](/docs/api/yii/web/request/index.md#property-csrfParam) and [`$csrfToken`](/docs/api/yii/web/request/index.md#property-csrfToken) via `yii.getCsrfParam()` and
`yii.getCsrfToken()`, respectively. The [`YiiAsset`](/docs/api/yii/web/yiiasset/index.md) asset must be registered.
You also need to include CSRF meta tags in your pages by using [`Html::csrfMetaTags()`](/docs/api/yii/helpers/basehtml/index.md#method-csrfMetaTags).

For SPA, you can use CSRF validation by custom header with a random or an empty value.
Include a header with the name specified by [`$csrfHeader`](/docs/api/yii/web/request/index.md#property-csrfHeader) to requests that must be validated.
Warning! CSRF validation by custom header can be used only for same-origin requests or
with CORS configured to allow requests from the list of specific origins only.

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

```php
public string[] $ipHeaders = ['X-Forwarded-For']
```

List of headers where proxies store the real client IP.

It's not advisable to put insecure headers here.
To use the `Forwarded` header according to RFC 7239, the header must be added to [`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders) list.
The match of header names is case-insensitive.

**Since**

2.0.13

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

```php
public string $method
```

Request method, such as GET, POST, HEAD, PUT, PATCH, DELETE.

The value
returned is turned into upper case.

**Access**

Read-only (virtual property).

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

```php
public string $methodParam = '_method'
```

The name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE request tunneled through POST.

Defaults to '_method'.

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

```php
public array $parsers = []
```

The parsers for converting the raw HTTP request body into [`$bodyParams`](/docs/api/yii/web/request/index.md#property-bodyParams).

The array keys are the request `Content-Types`, and the array values are the
corresponding configurations for [creating the parser objects](/docs/api/yii/baseyii/index.md#method-createObject).
A parser must implement the [`RequestParserInterface`](/docs/api/yii/web/requestparserinterface/index.md).

To enable parsing for JSON requests you can use the [`JsonParser`](/docs/api/yii/web/jsonparser/index.md) class like in the following example:

```
[
    'application/json' => 'yii\web\JsonParser',
]
```

To register a parser for parsing all request types you can use `'*'` as the array key.
This one will be used as a fallback in case no other types match.

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

```php
public string $pathInfo
```

Part of the request URL that is after the entry script and before the question mark.

Note, the returned path info is already URL-decoded.

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

```php
public string[] $portHeaders = ['X-Forwarded-Port']
```

List of headers where proxies store the real request port.

It's not advisable to put insecure headers here.
To use the `Forwarded Port`, the header must be added to [`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders) list.
The match of header names is case-insensitive.

**Since**

2.0.46

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

```php
public array $secureHeaders = ['X-Forwarded-For', 'X-Forwarded-Host', 'X-Forwarded-Proto', 'X-Forwarded-Port', 'Front-End-Https', 'X-Rewrite-Url', 'X-Original-Host']
```

Lists of headers that are, by default, subject to the trusted host configuration.

These headers will be filtered unless explicitly allowed in [`$trustedHosts`](/docs/api/yii/web/request/index.md#property-trustedHosts).
If the list contains the `Forwarded` header, processing will be done according to RFC 7239.
The match of header names is case-insensitive.

**Since**

2.0.13

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

```php
public array $secureProtocolHeaders = ['X-Forwarded-Proto' => ['https'], 'Front-End-Https' => ['on']]
```

List of headers to check for determining whether the connection is made via HTTPS.

The array keys are header names and the array value is a list of header values that indicate a secure connection.
The match of header names and values is case-insensitive.
It's not advisable to put insecure headers here.

**Since**

2.0.13

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

```php
public array $trustedHosts = []
```

The configuration for trusted security related headers.

An array key is an IPv4 or IPv6 IP address in CIDR notation for matching a client.

An array value is a list of headers to trust. These will be matched against
[`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders) to determine which headers are allowed to be sent by a specified host.
The case of the header names must be the same as specified in [`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders).

For example, to trust all headers listed in [`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders) for IP addresses
in range `192.168.0.0-192.168.0.254` write the following:

```
[
    '192.168.0.0/24',
]
```

To trust just the `X-Forwarded-For` header from `10.0.0.1`, use:

```
[
    '10.0.0.1' => ['X-Forwarded-For']
]
```

Default is to trust all headers except those listed in [`$secureHeaders`](/docs/api/yii/web/request/index.md#property-secureHeaders) from all hosts.
Matches are tried in order and searching is stopped when IP matches.

> Info: Matching is performed using [`IpValidator`](/docs/api/yii/validators/ipvalidator/index.md).
See IpValidator::setRanges()
and [`IpValidator::$networks`](/docs/api/yii/validators/ipvalidator/index.md#property-networks) for advanced matching.

**Since**

2.0.13

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

```php
public string $url
```

The currently requested relative URL.

Note that the URI returned may be URL-encoded
depending on the client.

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

```php
public bool $validateCsrfHeaderOnly = false
```

Whether to use custom header only to CSRF validation of SPA.

Defaults to false.
If false and [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) is true, CSRF validation by token will used.
Warning! CSRF validation by custom header can be used for Yii API applications only.

## Method details

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

```php
public function get(string|null $name = null, mixed $defaultValue = null): ($name is null ? array : mixed)
```

Returns GET parameter with a given name. If name isn't specified, returns an array of all GET parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string\|null` | The parameter name |
| `$defaultValue` | `mixed` | The default parameter value if the parameter does not exist. |

**Returns**

`($name is null ? array : mixed)`

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

```php
public function getAbsoluteUrl(): string
```

Returns the currently requested absolute URL.

This is a shortcut to the concatenation of [`$hostInfo`](/docs/api/yii/web/request/index.md#property-hostInfo) and [`$url`](/docs/api/yii/web/request/index.md#property-url).

**Returns**

`string`: The currently requested absolute URL.

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

```php
public function getAcceptableContentTypes(): array
```

Returns the content types acceptable by the end user.

This is determined by the `Accept` HTTP header. For example,

```
$_SERVER['HTTP_ACCEPT'] = 'text/plain; q=0.5, application/json; version=1.0, application/xml; version=2.0;';
$types = $request->getAcceptableContentTypes();
print_r($types);
// displays:
// [
//     'application/json' => ['q' => 1, 'version' => '1.0'],
//      'application/xml' => ['q' => 1, 'version' => '2.0'],
//           'text/plain' => ['q' => 0.5],
// ]
```

**Returns**

`array`: The content types ordered by the quality score. Types with the highest scores will be returned first. The array keys are the content types, while the array values are the corresponding quality score and other parameters as given in the header.

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

```php
public function getAcceptableLanguages(): array
```

Returns the languages acceptable by the end user.

This is determined by the `Accept-Language` HTTP header.

**Returns**

`array`: The languages ordered by the preference level. The first element represents the most preferred language.

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

```php
public function getAuthCredentials(): array
```

**Returns**

`array`: That contains exactly two elements: - 0: the username sent via HTTP authentication, `null` if the username is not given - 1: the password sent via HTTP authentication, `null` if the password is not given

**Since**

2.0.13

**See also**

- [`getAuthUser()`](/docs/api/yii/web/request/index.md#method-getAuthUser) (to get only username)
- [`getAuthPassword()`](/docs/api/yii/web/request/index.md#method-getAuthPassword) (to get only password)

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

```php
public function getAuthPassword(): string|null
```

**Returns**

`string|null`: The password sent via HTTP authentication, `null` if the password is not given

**See also**

- [`getAuthCredentials()`](/docs/api/yii/web/request/index.md#method-getAuthCredentials) (to get both username and password in one call)

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

```php
public function getAuthUser(): string|null
```

**Returns**

`string|null`: The username sent via HTTP authentication, `null` if the username is not given

**See also**

- [`getAuthCredentials()`](/docs/api/yii/web/request/index.md#method-getAuthCredentials) (to get both username and password in one call)

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

```php
public function getBaseUrl(): string
```

Returns the relative URL for the application.

This is similar to [`$scriptUrl`](/docs/api/yii/web/request/index.md#property-scriptUrl) except that it does not include the script file name,
and the ending slashes are removed.

**Returns**

`string`: The relative URL for the application

**See also**

- [`setScriptUrl()`](/docs/api/yii/web/request/index.md#method-setScriptUrl)

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

```php
public function getBodyParam(string $name, mixed $defaultValue = null): mixed
```

Returns the named request body parameter value.

If the parameter does not exist, the second parameter passed to this method will be returned.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` | The parameter name |
| `$defaultValue` | `mixed` | The default parameter value if the parameter does not exist. |

**Returns**

`mixed`: The parameter value

**See also**

- [`getBodyParams()`](/docs/api/yii/web/request/index.md#method-getBodyParams)
- [`setBodyParams()`](/docs/api/yii/web/request/index.md#method-setBodyParams)

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

```php
public function getBodyParams(): mixed
```

Returns the request parameters given in the request body.

Request parameters are determined using the parsers configured in [`$parsers`](/docs/api/yii/web/request/index.md#property-parsers) property.
If no parsers are configured for the current [`$contentType`](/docs/api/yii/web/request/index.md#property-contentType) it uses the PHP function `mb_parse_str()`
to parse the [request body](/docs/api/yii/web/request/index.md#property-rawBody).

**Returns**

`mixed`: The request parameters given in the request body.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if a registered parser does not implement the [`RequestParserInterface`](/docs/api/yii/web/requestparserinterface/index.md).

**See also**

- [`getMethod()`](/docs/api/yii/web/request/index.md#method-getMethod)
- [`getBodyParam()`](/docs/api/yii/web/request/index.md#method-getBodyParam)
- [`setBodyParams()`](/docs/api/yii/web/request/index.md#method-setBodyParams)

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

```php
public function getContentType(): string
```

Returns request content-type
The Content-Type header field indicates the MIME type of the data
contained in [`getRawBody()`](/docs/api/yii/web/request/index.md#method-getRawBody) or, in the case of the HEAD method, the
media type that would have been sent had the request been a GET.

For the MIME-types the user expects in response, see [`$acceptableContentTypes`](/docs/api/yii/web/request/index.md#property-acceptableContentTypes).

**Returns**

`string`: Request content-type. Empty string is returned if this information is not available.

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

```php
public function getCookies(): yii\web\CookieCollection
```

Returns the cookie collection.

Through the returned cookie collection, you may access a cookie using the following syntax:

```
$cookie = $request->cookies['name']
if ($cookie !== null) {
    $value = $cookie->value;
}

// alternatively
$value = $request->cookies->getValue('name');
```

**Returns**

[`CookieCollection`](/docs/api/yii/web/cookiecollection/index.md): The cookie collection.

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

```php
public function getCsrfToken(bool $regenerate = false): null|string
```

Returns the token used to perform CSRF validation.

This token is generated in a way to prevent [BREACH attacks](https://en.wikipedia.org/wiki/BREACH). It may be passed
along via a hidden field of an HTML form or an HTTP header value to support CSRF validation.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$regenerate` | `bool` | Whether to regenerate CSRF token. When this parameter is true, each time this method is called, a new CSRF token will be generated and persisted (in session or cookie). |

**Returns**

`null|string`: The token used to perform CSRF validation. Null is returned if the [`$validateCsrfHeaderOnly`](/docs/api/yii/web/request/index.md#property-validateCsrfHeaderOnly) is true.

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

```php
public function getCsrfTokenFromHeader(): string|null
```

**Returns**

`string|null`: The CSRF token sent via [`$csrfHeader`](/docs/api/yii/web/request/index.md#property-csrfHeader) by browser. Null is returned if no such header is sent.

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

```php
public function getETags(): array
```

Gets the Etags.

**Returns**

`array`: The entity tags

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

```php
public function getHeaders(): yii\web\HeaderCollection
```

Returns the header collection.

The header collection contains incoming HTTP headers.

**Returns**

[`HeaderCollection`](/docs/api/yii/web/headercollection/index.md): The header collection

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

```php
public function getHostInfo(): string|null
```

Returns the schema and host part of the current request URL.

The returned URL does not have an ending slash.

By default this value is based on the user request information. This method will
return the value of `$_SERVER['HTTP_HOST']` if it is available or `$_SERVER['SERVER_NAME']` if not.
You may want to check out the [PHP documentation](https://www.php.net/manual/en/reserved.variables.server.php)
for more information on these variables.

You may explicitly specify it by setting the [hostInfo](/docs/api/yii/web/request/index.md#method-setHostInfo) property.

> Warning: Dependent on the server configuration this information may not be
> reliable and [may be faked by the user sending the HTTP request](https://www.acunetix.com/vulnerabilities/web/host-header-attack).
> If the webserver is configured to serve the same site independent of the value of
> the `Host` header, this value is not reliable. In such situations you should either
> fix your webserver configuration or explicitly set the value by setting the [hostInfo](/docs/api/yii/web/request/index.md#method-setHostInfo) property.
> If you don't have access to the server configuration, you can setup [`HostControl`](/docs/api/yii/filters/hostcontrol/index.md) filter at
> application level in order to protect against such kind of attack.

**Returns**

`string|null`: Schema and hostname part (with port number if needed) of the request URL (e.g. `https://www.yiiframework.com`), null if can't be obtained from `$_SERVER` and wasn't set.

**See also**

- [`setHostInfo()`](/docs/api/yii/web/request/index.md#method-setHostInfo)

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

```php
public function getHostName(): string|null
```

Returns the host part of the current request URL.

Value is calculated from current [hostInfo](/docs/api/yii/web/request/index.md#method-getHostInfo) property.

> Warning: The content of this value may not be reliable, dependent on the server
> configuration. Please refer to [`getHostInfo()`](/docs/api/yii/web/request/index.md#method-getHostInfo) for more information.

**Returns**

`string|null`: Hostname part of the request URL (e.g. `www.yiiframework.com`)

**Since**

2.0.10

**See also**

- [`getHostInfo()`](/docs/api/yii/web/request/index.md#method-getHostInfo)

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

```php
public function getIsAjax(): bool
```

Returns whether this is an AJAX (XMLHttpRequest) request.

Note that in case of cross domain requests, browser doesn't set the X-Requested-With header by default:
https://stackoverflow.com/questions/8163703/cross-domain-ajax-doesnt-send-x-requested-with-header

In case you are using `fetch()`, pass header manually:

```
fetch(url, {
   method: 'GET',
   headers: {'X-Requested-With': 'XMLHttpRequest'}
})
```

**Returns**

`bool`: Whether this is an AJAX (XMLHttpRequest) request.

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

```php
public function getIsDelete(): bool
```

Returns whether this is a DELETE request.

**Returns**

`bool`: Whether this is a DELETE request.

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

```php
public function getIsFlash(): bool
```

Returns whether this is an Adobe Flash or Flex request.

**Returns**

`bool`: Whether this is an Adobe Flash or Adobe Flex request.

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

```php
public function getIsGet(): bool
```

Returns whether this is a GET request.

**Returns**

`bool`: Whether this is a GET request.

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

```php
public function getIsHead(): bool
```

Returns whether this is a HEAD request.

**Returns**

`bool`: Whether this is a HEAD request.

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

```php
public function getIsOptions(): bool
```

Returns whether this is an OPTIONS request.

**Returns**

`bool`: Whether this is a OPTIONS request.

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

```php
public function getIsPatch(): bool
```

Returns whether this is a PATCH request.

**Returns**

`bool`: Whether this is a PATCH request.

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

```php
public function getIsPjax(): bool
```

Returns whether this is a PJAX request.

**Returns**

`bool`: Whether this is a PJAX request

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

```php
public function getIsPost(): bool
```

Returns whether this is a POST request.

**Returns**

`bool`: Whether this is a POST request.

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

```php
public function getIsPut(): bool
```

Returns whether this is a PUT request.

**Returns**

`bool`: Whether this is a PUT request.

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

```php
public function getIsSecureConnection(): bool
```

Return if the request is sent via secure channel (https).

**Returns**

`bool`: If the request is sent via secure channel (https)

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

```php
public function getMethod(): string
```

Returns the method of the current request (e.g. GET, POST, HEAD, PUT, PATCH, DELETE).

**Returns**

`string`: Request method, such as GET, POST, HEAD, PUT, PATCH, DELETE. The value returned is turned into upper case.

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

```php
public function getOrigin(): string|null
```

Returns the URL origin of a CORS request.

The return value is taken from the `Origin` [header](/docs/api/yii/web/request/index.md#method-getHeaders) sent by the browser.

Note that the origin request header indicates where a fetch originates from.
It doesn't include any path information, but only the server name.
It is sent with a CORS requests, as well as with POST requests.
It is similar to the referer header, but, unlike this header, it doesn't disclose the whole path.
Please refer to <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin> for more information.

**Returns**

`string|null`: URL origin of a CORS request, `null` if not available.

**Since**

2.0.13

**See also**

- [`getHeaders()`](/docs/api/yii/web/request/index.md#method-getHeaders)

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

```php
public function getPathInfo(): string
```

Returns the path info of the currently requested URL.

A path info refers to the part that is after the entry script and before the question mark (query string).
The starting and ending slashes are both removed.

**Returns**

`string`: Part of the request URL that is after the entry script and before the question mark. Note, the returned path info is already URL-decoded.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the path info cannot be determined due to unexpected server configuration

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

```php
public function getPort(): int
```

Returns the port to use for insecure requests.

Defaults to 80, or the port specified by the server if the current
request is insecure.

**Returns**

`int`: Port number for insecure requests.

**See also**

- [`setPort()`](/docs/api/yii/web/request/index.md#method-setPort)

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

```php
public function getPreferredLanguage(array $languages = []): string
```

Returns the user-preferred language that should be used by this application.

The language resolution is based on the user preferred languages and the languages
supported by the application. The method will try to find the best match.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$languages` | `array` | A list of the languages supported by the application. If this is empty, the current application language will be returned without further processing. |

**Returns**

`string`: The language that the application should use.

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

```php
public function getQueryParam(string $name, mixed $defaultValue = null): mixed
```

Returns the named GET parameter value.

If the GET parameter does not exist, the second parameter passed to this method will be returned.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` | The GET parameter name. |
| `$defaultValue` | `mixed` | The default parameter value if the GET parameter does not exist. |

**Returns**

`mixed`: The GET parameter value

**See also**

- [`getBodyParam()`](/docs/api/yii/web/request/index.md#method-getBodyParam)

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

```php
public function getQueryParams(): array
```

Returns the request parameters given in the [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString).

This method will return the contents of `$_GET` if params where not explicitly set.

**Returns**

`array`: The request GET parameter values.

**See also**

- [`setQueryParams()`](/docs/api/yii/web/request/index.md#method-setQueryParams)

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

```php
public function getQueryString(): string
```

Returns part of the request URL that is after the question mark.

**Returns**

`string`: Part of the request URL that is after the question mark

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

```php
public function getRawBody(): string
```

Returns the raw HTTP request body.

**Returns**

`string`: The request body

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

```php
public function getReferrer(): string|null
```

Returns the URL referrer.

**Returns**

`string|null`: URL referrer, null if not available

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

```php
public function getRemoteHost(): string|null
```

Returns the host name of the other end of this connection.

This is always the next hop, any headers are ignored.

**Returns**

`string|null`: Remote host name, `null` if not available

**Since**

2.0.13

**See also**

- [`getUserHost()`](/docs/api/yii/web/request/index.md#method-getUserHost)
- [`getRemoteIP()`](/docs/api/yii/web/request/index.md#method-getRemoteIP)

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

```php
public function getRemoteIP(): string|null
```

Returns the IP on the other end of this connection.

This is always the next hop, any headers are ignored.

**Returns**

`string|null`: Remote IP address, `null` if not available.

**Since**

2.0.13

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

```php
public function getScriptFile(): string
```

Returns the entry script file path.

The default implementation will simply return `$_SERVER['SCRIPT_FILENAME']`.

**Returns**

`string`: The entry script file path

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md)

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

```php
public function getScriptUrl(): string
```

Returns the relative URL of the entry script.

The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework.

**Returns**

`string`: The relative URL of the entry script.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if unable to determine the entry script URL

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

```php
public function getSecurePort(): int
```

Returns the port to use for secure requests.

Defaults to 443, or the port specified by the server if the current
request is secure.

**Returns**

`int`: Port number for secure requests.

**See also**

- [`setSecurePort()`](/docs/api/yii/web/request/index.md#method-setSecurePort)

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

```php
public function getServerName(): string|null
```

Returns the server name.

**Returns**

`string|null`: Server name, null if not available

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

```php
public function getServerPort(): int|null
```

Returns the server port number. If a port is specified via a forwarding header (e.g. 'X-Forwarded-Port')
and the remote host is a "trusted host" the that port will be used (see [`$portHeaders`](/docs/api/yii/web/request/index.md#property-portHeaders)),
otherwise the default server port will be returned.

**Returns**

`int|null`: Server port number, null if not available

**See also**

- [`$portHeaders`](/docs/api/yii/web/request/index.md#property-portHeaders)

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

```php
public function getUrl(): string
```

Returns the currently requested relative URL.

This refers to the portion of the URL that is after the [`$hostInfo`](/docs/api/yii/web/request/index.md#property-hostInfo) part.
It includes the [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString) part if any.

**Returns**

`string`: The currently requested relative URL. Note that the URI returned may be URL-encoded depending on the client.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the URL cannot be determined due to unusual server configuration

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

```php
public function getUserAgent(): string|null
```

Returns the user agent.

**Returns**

`string|null`: User agent, null if not available

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

```php
public function getUserHost(): string|null
```

Returns the user host name.

The HOST is determined using headers and / or `$_SERVER` variables.

**Returns**

`string|null`: User host name, null if not available

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

```php
public function getUserIP(): string|null
```

Returns the user IP address.

The IP is determined using headers and / or `$_SERVER` variables.

**Returns**

`string|null`: User IP address, null if not available

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

```php
public function parseAcceptHeader(string $header): array
```

Parses the given `Accept` (or `Accept-Language`) header.

This method will return the acceptable values with their quality scores and the corresponding parameters
as specified in the given `Accept` header. The array keys of the return value are the acceptable values,
while the array values consisting of the corresponding quality scores and parameters. The acceptable
values with the highest quality scores will be returned first. For example,

```
$header = 'text/plain; q=0.5, application/json; version=1.0, application/xml; version=2.0;';
$accepts = $request->parseAcceptHeader($header);
print_r($accepts);
// displays:
// [
//     'application/json' => ['q' => 1, 'version' => '1.0'],
//      'application/xml' => ['q' => 1, 'version' => '2.0'],
//           'text/plain' => ['q' => 0.5],
// ]
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$header` | `string` | The header to be parsed |

**Returns**

`array`: The acceptable values ordered by their quality score. The values with the highest scores will be returned first.

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

```php
public function post(string|null $name = null, mixed $defaultValue = null): mixed
```

Returns POST parameter with a given name. If name isn't specified, returns an array of all POST parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string\|null` | The parameter name |
| `$defaultValue` | `mixed` | The default parameter value if the parameter does not exist. |

**Returns**

`mixed`

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

```php
public function resolve(): array
```

Resolves the current request into a route and the associated parameters.

**Returns**

`array`: The first element is the route, and the second is the associated parameters.

**Throws**

- [`NotFoundHttpException`](/docs/api/yii/web/notfoundhttpexception/index.md): if the request cannot be resolved.

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

```php
public function setAcceptableContentTypes(array $value): mixed
```

Sets the acceptable content types.

Please refer to [`getAcceptableContentTypes()`](/docs/api/yii/web/request/index.md#method-getAcceptableContentTypes) on the format of the parameter.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `array` | The content types that are acceptable by the end user. They should be ordered by the preference level. |

**Returns**

`mixed`

**See also**

- [`getAcceptableContentTypes()`](/docs/api/yii/web/request/index.md#method-getAcceptableContentTypes)
- [`parseAcceptHeader()`](/docs/api/yii/web/request/index.md#method-parseAcceptHeader)

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

```php
public function setAcceptableLanguages(array $value): mixed
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `array` | The languages that are acceptable by the end user. They should be ordered by the preference level. |

**Returns**

`mixed`

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

```php
public function setBaseUrl(string $value): mixed
```

Sets the relative URL for the application.

By default the URL is determined based on the entry script URL.
This setter is provided in case you want to change this behavior.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The relative URL for the application |

**Returns**

`mixed`

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

```php
public function setBodyParams(mixed $values): mixed
```

Sets the request body parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$values` | `mixed` | The request body parameters (name-value pairs) |

**Returns**

`mixed`

**See also**

- [`getBodyParams()`](/docs/api/yii/web/request/index.md#method-getBodyParams)

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

```php
public function setHostInfo(string|null $value): mixed
```

Sets the schema and host part of the application URL.

This setter is provided in case the schema and hostname cannot be determined
on certain Web servers.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | The schema and host part of the application URL. The trailing slashes will be removed. |

**Returns**

`mixed`

**See also**

- [`getHostInfo()`](/docs/api/yii/web/request/index.md#method-getHostInfo) (for security related notes on this property.)

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

```php
public function setPathInfo(string $value): mixed
```

Sets the path info of the current request.

This method is mainly provided for testing purpose.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The path info of the current request |

**Returns**

`mixed`

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

```php
public function setPort(int $value): mixed
```

Sets the port to use for insecure requests.

This setter is provided in case a custom port is necessary for certain
server configurations.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int` | Port number. |

**Returns**

`mixed`

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

```php
public function setQueryParams(array $values): mixed
```

Sets the request [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString) parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$values` | `array` | The request query parameters (name-value pairs) |

**Returns**

`mixed`

**See also**

- [`getQueryParam()`](/docs/api/yii/web/request/index.md#method-getQueryParam)
- [`getQueryParams()`](/docs/api/yii/web/request/index.md#method-getQueryParams)

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

```php
public function setRawBody(string $rawBody): mixed
```

Sets the raw HTTP request body, this method is mainly used by test scripts to simulate raw HTTP requests.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$rawBody` | `string` | The request body |

**Returns**

`mixed`

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

```php
public function setScriptFile(string $value): mixed
```

Sets the entry script file path.

The entry script file path normally can be obtained from `$_SERVER['SCRIPT_FILENAME']`.
If your server configuration does not return the correct value, you may configure
this property to make it right.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The entry script file path. |

**Returns**

`mixed`

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

```php
public function setScriptUrl(string $value): mixed
```

Sets the relative URL for the application entry script.

This setter is provided in case the entry script URL cannot be determined
on certain Web servers.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The relative URL for the application entry script. |

**Returns**

`mixed`

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

```php
public function setSecurePort(int $value): mixed
```

Sets the port to use for secure requests.

This setter is provided in case a custom port is necessary for certain
server configurations.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int` | Port number. |

**Returns**

`mixed`

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

```php
public function setUrl(string $value): mixed
```

Sets the currently requested relative URL.

The URI must refer to the portion that is after [`$hostInfo`](/docs/api/yii/web/request/index.md#property-hostInfo).
Note that the URI should be URL-encoded.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | The request URI to be set |

**Returns**

`mixed`

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

```php
public function validateCsrfToken(string|null $clientSuppliedToken = null): bool
```

Performs the CSRF validation.

This method will validate the user-provided CSRF token by comparing it with the one stored in cookie or session.
This method is mainly called in [`Controller::beforeAction()`](/docs/api/yii/web/controller/index.md#method-beforeAction).

Note that the method will NOT perform CSRF validation if [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) is false or the HTTP method
is among GET, HEAD or OPTIONS.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$clientSuppliedToken` | `string\|null` | The user-provided CSRF token to be validated. If null, the token will be retrieved from the [`$csrfParam`](/docs/api/yii/web/request/index.md#property-csrfParam) POST field or HTTP header. This parameter is available since version 2.0.4. |

**Returns**

`bool`: Whether CSRF token is valid. If [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation) is false, this method will return true.

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

```php
protected function createCsrfCookie(string $token): yii\web\Cookie
```

Creates a cookie with a randomly generated CSRF token.

Initial values specified in [`$csrfCookie`](/docs/api/yii/web/request/index.md#property-csrfCookie) will be applied to the generated cookie.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$token` | `string` | The CSRF token |

**Returns**

[`Cookie`](/docs/api/yii/web/cookie/index.md): The generated cookie

**See also**

- [`$enableCsrfValidation`](/docs/api/yii/web/request/index.md#property-enableCsrfValidation)

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

```php
protected function filterHeaders(yii\web\HeaderCollection $headerCollection): mixed
```

Filters headers according to the [`$trustedHosts`](/docs/api/yii/web/request/index.md#property-trustedHosts).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$headerCollection` | [`HeaderCollection`](/docs/api/yii/web/headercollection/index.md) |  |

**Returns**

`mixed`

**Since**

2.0.13

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

```php
protected function generateCsrfToken(): string
```

Generates an unmasked random token used to perform CSRF validation.

**Returns**

`string`: The random token for CSRF validation.

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

```php
protected function getIpValidator(): yii\validators\IpValidator
```

Creates instance of [`IpValidator`](/docs/api/yii/validators/ipvalidator/index.md).

You can override this method to adjust validator or implement different matching strategy.

**Returns**

[`yii\validators\IpValidator`](/docs/api/yii/validators/ipvalidator/index.md)

**Since**

2.0.13

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

```php
protected function getSecureForwardedHeaderParts(): array
```

Returns decoded forwarded header

**Returns**

`array`

**Since**

2.0.31

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

```php
protected function getSecureForwardedHeaderTrustedPart(string $token): string|null
```

Gets first `Forwarded` header value for token

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$token` | `string` | Header token |

**Returns**

`string|null`

**Since**

2.0.31

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

```php
protected function getSecureForwardedHeaderTrustedParts(): array
```

Gets only trusted `Forwarded` header parts

**Returns**

`array`

**Since**

2.0.31

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

```php
protected function getTrustedHeaders(): array
```

Trusted headers according to the [`$trustedHosts`](/docs/api/yii/web/request/index.md#property-trustedHosts).

**Returns**

`array`

**Since**

2.0.28

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

```php
protected function getUserIpFromIpHeader(string $ips): string|null
```

Return user IP's from IP header.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$ips` | `string` | Comma separated IP list |

**Returns**

`string|null`: IP as string. Null is returned if IP can not be determined from header.

**Since**

2.0.28

**See also**

- [`getUserHost()`](/docs/api/yii/web/request/index.md#method-getUserHost)
- [`$ipHeaders`](/docs/api/yii/web/request/index.md#property-ipHeaders)
- [`getTrustedHeaders()`](/docs/api/yii/web/request/index.md#method-getTrustedHeaders)

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

```php
protected function getUserIpFromIpHeaders(): string|null
```

Returns the user IP address from [`$ipHeaders`](/docs/api/yii/web/request/index.md#property-ipHeaders).

**Returns**

`string|null`: User IP address, null if not available

**Since**

2.0.28

**See also**

- [`$ipHeaders`](/docs/api/yii/web/request/index.md#property-ipHeaders)

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

```php
protected function loadCookies(): array
```

Converts `$_COOKIE` into an array of [`Cookie`](/docs/api/yii/web/cookie/index.md).

**Returns**

`array`: The cookies obtained from request

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if [`$cookieValidationKey`](/docs/api/yii/web/request/index.md#property-cookieValidationKey) is not set when [`$enableCookieValidation`](/docs/api/yii/web/request/index.md#property-enableCookieValidation) is true

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

```php
protected function loadCsrfToken(): string|null
```

Loads the CSRF token from cookie or session.

**Returns**

`string|null`: The CSRF token loaded from cookie or session. Null is returned if the cookie or session does not have CSRF token.

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

```php
protected function resolvePathInfo(): string
```

Resolves the path info part of the currently requested URL.

A path info refers to the part that is after the entry script and before the question mark (query string).
The starting slashes are both removed (ending slashes will be kept).

**Returns**

`string`: Part of the request URL that is after the entry script and before the question mark. Note, the returned path info is decoded.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the path info cannot be determined due to unexpected server configuration

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

```php
protected function resolveRequestUri(): string|bool
```

Resolves the request URI portion for the currently requested URL.

This refers to the portion that is after the [`$hostInfo`](/docs/api/yii/web/request/index.md#property-hostInfo) part. It includes the [`$queryString`](/docs/api/yii/web/request/index.md#property-queryString) part if any.
The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework.

**Returns**

`string|bool`: The request URI portion for the currently requested URL. Note that the URI returned may be URL-encoded depending on the client.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the request URI cannot be determined due to unusual server configuration