Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/Request.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
301 // With the php's bug #66606, the php's built-in web server | 301 // With the php's bug #66606, the php's built-in web server |
302 // stores the Content-Type and Content-Length header values in | 302 // stores the Content-Type and Content-Length header values in |
303 // HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields. | 303 // HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields. |
304 $server = $_SERVER; | 304 $server = $_SERVER; |
305 if ('cli-server' === \PHP_SAPI) { | 305 if ('cli-server' === \PHP_SAPI) { |
306 if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) { | 306 if (\array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) { |
307 $server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH']; | 307 $server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH']; |
308 } | 308 } |
309 if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) { | 309 if (\array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) { |
310 $server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE']; | 310 $server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE']; |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 $request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $server); | 314 $request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $server); |
689 $key = self::HEADER_CLIENT_HOST; | 689 $key = self::HEADER_CLIENT_HOST; |
690 } elseif ('client_proto' === $key) { | 690 } elseif ('client_proto' === $key) { |
691 $key = self::HEADER_CLIENT_PROTO; | 691 $key = self::HEADER_CLIENT_PROTO; |
692 } elseif ('client_port' === $key) { | 692 } elseif ('client_port' === $key) { |
693 $key = self::HEADER_CLIENT_PORT; | 693 $key = self::HEADER_CLIENT_PORT; |
694 } elseif (!array_key_exists($key, self::$trustedHeaders)) { | 694 } elseif (!\array_key_exists($key, self::$trustedHeaders)) { |
695 throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key)); | 695 throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key)); |
696 } | 696 } |
697 | 697 |
698 self::$trustedHeaders[$key] = $value; | 698 self::$trustedHeaders[$key] = $value; |
699 | 699 |
720 { | 720 { |
721 if (2 > \func_num_args() || func_get_arg(1)) { | 721 if (2 > \func_num_args() || func_get_arg(1)) { |
722 @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED); | 722 @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED); |
723 } | 723 } |
724 | 724 |
725 if (!array_key_exists($key, self::$trustedHeaders)) { | 725 if (!\array_key_exists($key, self::$trustedHeaders)) { |
726 throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key)); | 726 throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key)); |
727 } | 727 } |
728 | 728 |
729 return self::$trustedHeaders[$key]; | 729 return self::$trustedHeaders[$key]; |
730 } | 730 } |
1344 * | 1344 * |
1345 * @see getRealMethod() | 1345 * @see getRealMethod() |
1346 */ | 1346 */ |
1347 public function getMethod() | 1347 public function getMethod() |
1348 { | 1348 { |
1349 if (null === $this->method) { | 1349 if (null !== $this->method) { |
1350 $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); | 1350 return $this->method; |
1351 | 1351 } |
1352 if ('POST' === $this->method) { | 1352 |
1353 if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) { | 1353 $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); |
1354 $this->method = strtoupper($method); | 1354 |
1355 } elseif (self::$httpMethodParameterOverride) { | 1355 if ('POST' !== $this->method) { |
1356 $method = $this->request->get('_method', $this->query->get('_method', 'POST')); | 1356 return $this->method; |
1357 if (\is_string($method)) { | 1357 } |
1358 $this->method = strtoupper($method); | 1358 |
1359 } | 1359 $method = $this->headers->get('X-HTTP-METHOD-OVERRIDE'); |
1360 } | 1360 |
1361 } | 1361 if (!$method && self::$httpMethodParameterOverride) { |
1362 } | 1362 $method = $this->request->get('_method', $this->query->get('_method', 'POST')); |
1363 | 1363 } |
1364 return $this->method; | 1364 |
1365 if (!\is_string($method)) { | |
1366 return $this->method; | |
1367 } | |
1368 | |
1369 $method = strtoupper($method); | |
1370 | |
1371 if (\in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) { | |
1372 return $this->method = $method; | |
1373 } | |
1374 | |
1375 if (!preg_match('/^[A-Z]++$/D', $method)) { | |
1376 throw new SuspiciousOperationException(sprintf('Invalid method override "%s".', $method)); | |
1377 } | |
1378 | |
1379 return $this->method = $method; | |
1365 } | 1380 } |
1366 | 1381 |
1367 /** | 1382 /** |
1368 * Gets the "real" request method. | 1383 * Gets the "real" request method. |
1369 * | 1384 * |
1460 * * _format request attribute | 1475 * * _format request attribute |
1461 * * $default | 1476 * * $default |
1462 * | 1477 * |
1463 * @param string|null $default The default format | 1478 * @param string|null $default The default format |
1464 * | 1479 * |
1465 * @return string The request format | 1480 * @return string|null The request format |
1466 */ | 1481 */ |
1467 public function getRequestFormat($default = 'html') | 1482 public function getRequestFormat($default = 'html') |
1468 { | 1483 { |
1469 if (null === $this->format) { | 1484 if (null === $this->format) { |
1470 $this->format = $this->attributes->get('_format'); | 1485 $this->format = $this->attributes->get('_format'); |