function Request::getMethod
Same name in this branch
- 11.1.x vendor/guzzlehttp/psr7/src/Request.php \GuzzleHttp\Psr7\Request::getMethod()
- 11.1.x vendor/symfony/browser-kit/Request.php \Symfony\Component\BrowserKit\Request::getMethod()
Gets the request "intended" method.
If the X-HTTP-Method-Override header is set, and if the method is a POST, then it is used to determine the "real" intended HTTP method.
The _method request parameter can also be used to determine the HTTP method, but only if enableHttpMethodParameterOverride() has been called.
The method is always an uppercased string.
See also
getRealMethod()
5 calls to Request::getMethod()
- Request::isMethod in vendor/
symfony/ http-foundation/ Request.php - Checks if the request method is of specified type.
- Request::isMethodCacheable in vendor/
symfony/ http-foundation/ Request.php - Checks whether the method is cacheable or not.
- Request::isMethodIdempotent in vendor/
symfony/ http-foundation/ Request.php - Checks whether or not the method is idempotent.
- Request::isMethodSafe in vendor/
symfony/ http-foundation/ Request.php - Checks whether or not the method is safe.
- Request::__toString in vendor/
symfony/ http-foundation/ Request.php
1 method overrides Request::getMethod()
- CliRequest::getMethod in vendor/
symfony/ console/ Debug/ CliRequest.php - Gets the request "intended" method.
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1154
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public function getMethod() : string {
if (null !== $this->method) {
return $this->method;
}
$this->method = strtoupper($this->server
->get('REQUEST_METHOD', 'GET'));
if ('POST' !== $this->method) {
return $this->method;
}
$method = $this->headers
->get('X-HTTP-METHOD-OVERRIDE');
if (!$method && self::$httpMethodParameterOverride) {
$method = $this->request
->get('_method', $this->query
->get('_method', 'POST'));
}
if (!\is_string($method)) {
return $this->method;
}
$method = strtoupper($method);
if (\in_array($method, [
'GET',
'HEAD',
'POST',
'PUT',
'DELETE',
'CONNECT',
'OPTIONS',
'PATCH',
'PURGE',
'TRACE',
], true)) {
return $this->method = $method;
}
if (!preg_match('/^[A-Z]++$/D', $method)) {
throw new SuspiciousOperationException('Invalid HTTP method override.');
}
return $this->method = $method;
}