Open Journal Systems  3.3.0
vendor/symfony/http-foundation/Request.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
17 
18 // Help opcache.preload discover always-needed symbols
19 class_exists(AcceptHeader::class);
20 class_exists(FileBag::class);
21 class_exists(HeaderBag::class);
22 class_exists(HeaderUtils::class);
23 class_exists(ParameterBag::class);
24 class_exists(ServerBag::class);
25 
39 class Request
40 {
41  const HEADER_FORWARDED = 0b00001; // When using RFC 7239
42  const HEADER_X_FORWARDED_FOR = 0b00010;
43  const HEADER_X_FORWARDED_HOST = 0b00100;
44  const HEADER_X_FORWARDED_PROTO = 0b01000;
45  const HEADER_X_FORWARDED_PORT = 0b10000;
46  const HEADER_X_FORWARDED_ALL = 0b11110; // All "X-Forwarded-*" headers
47  const HEADER_X_FORWARDED_AWS_ELB = 0b11010; // AWS ELB doesn't send X-Forwarded-Host
48 
49  const METHOD_HEAD = 'HEAD';
50  const METHOD_GET = 'GET';
51  const METHOD_POST = 'POST';
52  const METHOD_PUT = 'PUT';
53  const METHOD_PATCH = 'PATCH';
54  const METHOD_DELETE = 'DELETE';
55  const METHOD_PURGE = 'PURGE';
56  const METHOD_OPTIONS = 'OPTIONS';
57  const METHOD_TRACE = 'TRACE';
58  const METHOD_CONNECT = 'CONNECT';
59 
63  protected static $trustedProxies = [];
64 
68  protected static $trustedHostPatterns = [];
69 
73  protected static $trustedHosts = [];
74 
75  protected static $httpMethodParameterOverride = false;
76 
82  public $attributes;
83 
89  public $request;
90 
96  public $query;
97 
103  public $server;
104 
110  public $files;
111 
117  public $cookies;
118 
124  public $headers;
125 
129  protected $content;
130 
134  protected $languages;
135 
139  protected $charsets;
140 
144  protected $encodings;
145 
149  protected $acceptableContentTypes;
150 
154  protected $pathInfo;
155 
159  protected $requestUri;
160 
164  protected $baseUrl;
165 
169  protected $basePath;
170 
174  protected $method;
175 
179  protected $format;
180 
184  protected $session;
185 
189  protected $locale;
190 
194  protected $defaultLocale = 'en';
195 
199  protected static $formats;
200 
201  protected static $requestFactory;
202 
206  private $preferredFormat;
207  private $isHostValid = true;
208  private $isForwardedValid = true;
209 
210  private static $trustedHeaderSet = -1;
211 
212  private static $forwardedParams = [
213  self::HEADER_X_FORWARDED_FOR => 'for',
214  self::HEADER_X_FORWARDED_HOST => 'host',
215  self::HEADER_X_FORWARDED_PROTO => 'proto',
216  self::HEADER_X_FORWARDED_PORT => 'host',
217  ];
218 
228  private static $trustedHeaders = [
229  self::HEADER_FORWARDED => 'FORWARDED',
230  self::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
231  self::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
232  self::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
233  self::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
234  ];
235 
245  public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
246  {
248  }
249 
263  public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
264  {
265  $this->request = new ParameterBag($request);
266  $this->query = new ParameterBag($query);
267  $this->attributes = new ParameterBag($attributes);
268  $this->cookies = new ParameterBag($cookies);
269  $this->files = new FileBag($files);
270  $this->server = new ServerBag($server);
271  $this->headers = new HeaderBag($this->server->getHeaders());
272 
273  $this->content = $content;
274  $this->languages = null;
275  $this->charsets = null;
276  $this->encodings = null;
277  $this->acceptableContentTypes = null;
278  $this->pathInfo = null;
279  $this->requestUri = null;
280  $this->baseUrl = null;
281  $this->basePath = null;
282  $this->method = null;
283  $this->format = null;
284  }
285 
291  public static function createFromGlobals()
292  {
293  $request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
294 
295  if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
296  && \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
297  ) {
298  parse_str($request->getContent(), $data);
299  $request->request = new ParameterBag($data);
300  }
301 
302  return $request;
303  }
304 
321  public static function create($uri, $method = 'GET', $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
322  {
323  $server = array_replace([
324  'SERVER_NAME' => 'localhost',
325  'SERVER_PORT' => 80,
326  'HTTP_HOST' => 'localhost',
327  'HTTP_USER_AGENT' => 'Symfony',
328  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
329  'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
330  'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
331  'REMOTE_ADDR' => '127.0.0.1',
332  'SCRIPT_NAME' => '',
333  'SCRIPT_FILENAME' => '',
334  'SERVER_PROTOCOL' => 'HTTP/1.1',
335  'REQUEST_TIME' => time(),
336  ], $server);
337 
338  $server['PATH_INFO'] = '';
339  $server['REQUEST_METHOD'] = strtoupper($method);
340 
341  $components = parse_url($uri);
342  if (isset($components['host'])) {
343  $server['SERVER_NAME'] = $components['host'];
344  $server['HTTP_HOST'] = $components['host'];
345  }
346 
347  if (isset($components['scheme'])) {
348  if ('https' === $components['scheme']) {
349  $server['HTTPS'] = 'on';
350  $server['SERVER_PORT'] = 443;
351  } else {
352  unset($server['HTTPS']);
353  $server['SERVER_PORT'] = 80;
354  }
355  }
356 
357  if (isset($components['port'])) {
358  $server['SERVER_PORT'] = $components['port'];
359  $server['HTTP_HOST'] .= ':'.$components['port'];
360  }
361 
362  if (isset($components['user'])) {
363  $server['PHP_AUTH_USER'] = $components['user'];
364  }
365 
366  if (isset($components['pass'])) {
367  $server['PHP_AUTH_PW'] = $components['pass'];
368  }
369 
370  if (!isset($components['path'])) {
371  $components['path'] = '/';
372  }
373 
374  switch (strtoupper($method)) {
375  case 'POST':
376  case 'PUT':
377  case 'DELETE':
378  if (!isset($server['CONTENT_TYPE'])) {
379  $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
380  }
381  // no break
382  case 'PATCH':
383  $request = $parameters;
384  $query = [];
385  break;
386  default:
387  $request = [];
388  $query = $parameters;
389  break;
390  }
391 
392  $queryString = '';
393  if (isset($components['query'])) {
394  parse_str(html_entity_decode($components['query']), $qs);
395 
396  if ($query) {
397  $query = array_replace($qs, $query);
398  $queryString = http_build_query($query, '', '&');
399  } else {
400  $query = $qs;
401  $queryString = $components['query'];
402  }
403  } elseif ($query) {
404  $queryString = http_build_query($query, '', '&');
405  }
406 
407  $server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
408  $server['QUERY_STRING'] = $queryString;
409 
410  return self::createRequestFromFactory($query, $request, [], $cookies, $files, $server, $content);
411  }
412 
422  public static function setFactory($callable)
423  {
424  self::$requestFactory = $callable;
425  }
426 
439  public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
440  {
441  $dup = clone $this;
442  if (null !== $query) {
443  $dup->query = new ParameterBag($query);
444  }
445  if (null !== $request) {
446  $dup->request = new ParameterBag($request);
447  }
448  if (null !== $attributes) {
449  $dup->attributes = new ParameterBag($attributes);
450  }
451  if (null !== $cookies) {
452  $dup->cookies = new ParameterBag($cookies);
453  }
454  if (null !== $files) {
455  $dup->files = new FileBag($files);
456  }
457  if (null !== $server) {
458  $dup->server = new ServerBag($server);
459  $dup->headers = new HeaderBag($dup->server->getHeaders());
460  }
461  $dup->languages = null;
462  $dup->charsets = null;
463  $dup->encodings = null;
464  $dup->acceptableContentTypes = null;
465  $dup->pathInfo = null;
466  $dup->requestUri = null;
467  $dup->baseUrl = null;
468  $dup->basePath = null;
469  $dup->method = null;
470  $dup->format = null;
471 
472  if (!$dup->get('_format') && $this->get('_format')) {
473  $dup->attributes->set('_format', $this->get('_format'));
474  }
475 
476  if (!$dup->getRequestFormat(null)) {
477  $dup->setRequestFormat($this->getRequestFormat(null));
478  }
479 
480  return $dup;
481  }
482 
489  public function __clone()
490  {
491  $this->query = clone $this->query;
492  $this->request = clone $this->request;
493  $this->attributes = clone $this->attributes;
494  $this->cookies = clone $this->cookies;
495  $this->files = clone $this->files;
496  $this->server = clone $this->server;
497  $this->headers = clone $this->headers;
498  }
499 
505  public function __toString()
506  {
507  try {
508  $content = $this->getContent();
509  } catch (\LogicException $e) {
510  if (\PHP_VERSION_ID >= 70400) {
511  throw $e;
512  }
513 
514  return trigger_error($e, E_USER_ERROR);
515  }
516 
517  $cookieHeader = '';
518  $cookies = [];
519 
520  foreach ($this->cookies as $k => $v) {
521  $cookies[] = $k.'='.$v;
522  }
523 
524  if (!empty($cookies)) {
525  $cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
526  }
527 
528  return
529  sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
530  $this->headers.
531  $cookieHeader."\r\n".
532  $content;
533  }
534 
541  public function overrideGlobals()
542  {
543  $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));
544 
545  $_GET = $this->query->all();
546  $_POST = $this->request->all();
547  $_SERVER = $this->server->all();
548  $_COOKIE = $this->cookies->all();
549 
550  foreach ($this->headers->all() as $key => $value) {
551  $key = strtoupper(str_replace('-', '_', $key));
552  if (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
553  $_SERVER[$key] = implode(', ', $value);
554  } else {
555  $_SERVER['HTTP_'.$key] = implode(', ', $value);
556  }
557  }
558 
559  $request = ['g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE];
560 
561  $requestOrder = ini_get('request_order') ?: ini_get('variables_order');
562  $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
563 
564  $_REQUEST = [[]];
565 
566  foreach (str_split($requestOrder) as $order) {
567  $_REQUEST[] = $request[$order];
568  }
569 
570  $_REQUEST = array_merge(...$_REQUEST);
571  }
572 
583  public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
584  {
585  self::$trustedProxies = array_reduce($proxies, function ($proxies, $proxy) {
586  if ('REMOTE_ADDR' !== $proxy) {
587  $proxies[] = $proxy;
588  } elseif (isset($_SERVER['REMOTE_ADDR'])) {
589  $proxies[] = $_SERVER['REMOTE_ADDR'];
590  }
591 
592  return $proxies;
593  }, []);
594  self::$trustedHeaderSet = $trustedHeaderSet;
595  }
596 
602  public static function getTrustedProxies()
603  {
604  return self::$trustedProxies;
605  }
606 
612  public static function getTrustedHeaderSet()
613  {
614  return self::$trustedHeaderSet;
615  }
616 
624  public static function setTrustedHosts(array $hostPatterns)
625  {
626  self::$trustedHostPatterns = array_map(function ($hostPattern) {
627  return sprintf('{%s}i', $hostPattern);
628  }, $hostPatterns);
629  // we need to reset trusted hosts on trusted host patterns change
630  self::$trustedHosts = [];
631  }
632 
638  public static function getTrustedHosts()
639  {
641  }
642 
653  public static function normalizeQueryString($qs)
654  {
655  if ('' === ($qs ?? '')) {
656  return '';
657  }
658 
659  parse_str($qs, $qs);
660  ksort($qs);
661 
662  return http_build_query($qs, '', '&', PHP_QUERY_RFC3986);
663  }
664 
676  public static function enableHttpMethodParameterOverride()
677  {
678  self::$httpMethodParameterOverride = true;
679  }
680 
686  public static function getHttpMethodParameterOverride()
687  {
689  }
690 
705  public function get($key, $default = null)
706  {
707  if ($this !== $result = $this->attributes->get($key, $this)) {
708  return $result;
709  }
710 
711  if ($this !== $result = $this->query->get($key, $this)) {
712  return $result;
713  }
714 
715  if ($this !== $result = $this->request->get($key, $this)) {
716  return $result;
717  }
718 
719  return $default;
720  }
721 
727  public function getSession()
728  {
730  if (!$session instanceof SessionInterface && null !== $session) {
731  $this->setSession($session = $session());
732  }
733 
734  if (null === $session) {
735  @trigger_error(sprintf('Calling "%s()" when no session has been set is deprecated since Symfony 4.1 and will throw an exception in 5.0. Use "hasSession()" instead.', __METHOD__), E_USER_DEPRECATED);
736  // throw new \BadMethodCallException('Session has not been set.');
737  }
738 
739  return $session;
740  }
741 
748  public function hasPreviousSession()
749  {
750  // the check for $this->session avoids malicious users trying to fake a session cookie with proper name
751  return $this->hasSession() && $this->cookies->has($this->getSession()->getName());
752  }
753 
763  public function hasSession()
764  {
765  return null !== $this->session;
766  }
767 
768  public function setSession(SessionInterface $session)
769  {
770  $this->session = $session;
771  }
772 
776  public function setSessionFactory(callable $factory)
777  {
778  $this->session = $factory;
779  }
780 
794  public function getClientIps()
795  {
796  $ip = $this->server->get('REMOTE_ADDR');
797 
798  if (!$this->isFromTrustedProxy()) {
799  return [$ip];
800  }
801 
802  return $this->getTrustedValues(self::HEADER_X_FORWARDED_FOR, $ip) ?: [$ip];
803  }
804 
823  public function getClientIp()
824  {
825  $ipAddresses = $this->getClientIps();
826 
827  return $ipAddresses[0];
828  }
829 
835  public function getScriptName()
836  {
837  return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME', ''));
838  }
839 
854  public function getPathInfo()
855  {
856  if (null === $this->pathInfo) {
857  $this->pathInfo = $this->preparePathInfo();
858  }
859 
861  }
862 
875  public function getBasePath()
876  {
877  if (null === $this->basePath) {
878  $this->basePath = $this->prepareBasePath();
879  }
880 
881  return $this->basePath;
882  }
883 
894  public function getBaseUrl()
895  {
896  if (null === $this->baseUrl) {
897  $this->baseUrl = $this->prepareBaseUrl();
898  }
899 
900  return $this->baseUrl;
901  }
902 
908  public function getScheme()
909  {
910  return $this->isSecure() ? 'https' : 'http';
911  }
912 
923  public function getPort()
924  {
925  if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_X_FORWARDED_PORT)) {
926  $host = $host[0];
927  } elseif ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_X_FORWARDED_HOST)) {
928  $host = $host[0];
929  } elseif (!$host = $this->headers->get('HOST')) {
930  return $this->server->get('SERVER_PORT');
931  }
932 
933  if ('[' === $host[0]) {
934  $pos = strpos($host, ':', strrpos($host, ']'));
935  } else {
936  $pos = strrpos($host, ':');
937  }
938 
939  if (false !== $pos && $port = substr($host, $pos + 1)) {
940  return (int) $port;
941  }
942 
943  return 'https' === $this->getScheme() ? 443 : 80;
944  }
945 
951  public function getUser()
952  {
953  return $this->headers->get('PHP_AUTH_USER');
954  }
955 
961  public function getPassword()
962  {
963  return $this->headers->get('PHP_AUTH_PW');
964  }
965 
971  public function getUserInfo()
972  {
973  $userinfo = $this->getUser();
974 
975  $pass = $this->getPassword();
976  if ('' != $pass) {
977  $userinfo .= ":$pass";
978  }
979 
980  return $userinfo;
981  }
982 
990  public function getHttpHost()
991  {
992  $scheme = $this->getScheme();
993  $port = $this->getPort();
994 
995  if (('http' == $scheme && 80 == $port) || ('https' == $scheme && 443 == $port)) {
996  return $this->getHost();
997  }
998 
999  return $this->getHost().':'.$port;
1000  }
1001 
1007  public function getRequestUri()
1008  {
1009  if (null === $this->requestUri) {
1010  $this->requestUri = $this->prepareRequestUri();
1011  }
1012 
1013  return $this->requestUri;
1014  }
1015 
1024  public function getSchemeAndHttpHost()
1025  {
1026  return $this->getScheme().'://'.$this->getHttpHost();
1027  }
1028 
1036  public function getUri()
1037  {
1038  if (null !== $qs = $this->getQueryString()) {
1039  $qs = '?'.$qs;
1040  }
1041 
1042  return $this->getSchemeAndHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs;
1043  }
1044 
1052  public function getUriForPath($path)
1053  {
1054  return $this->getSchemeAndHttpHost().$this->getBaseUrl().$path;
1055  }
1076  public function getRelativeUriForPath($path)
1077  {
1078  // be sure that we are dealing with an absolute path
1079  if (!isset($path[0]) || '/' !== $path[0]) {
1080  return $path;
1081  }
1082 
1083  if ($path === $basePath = $this->getPathInfo()) {
1084  return '';
1085  }
1086 
1087  $sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath);
1088  $targetDirs = explode('/', substr($path, 1));
1089  array_pop($sourceDirs);
1090  $targetFile = array_pop($targetDirs);
1091 
1092  foreach ($sourceDirs as $i => $dir) {
1093  if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) {
1094  unset($sourceDirs[$i], $targetDirs[$i]);
1095  } else {
1096  break;
1097  }
1098  }
1099 
1100  $targetDirs[] = $targetFile;
1101  $path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
1103  // A reference to the same base directory or an empty subdirectory must be prefixed with "./".
1104  // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
1105  // as the first segment of a relative-path reference, as it would be mistaken for a scheme name
1106  // (see https://tools.ietf.org/html/rfc3986#section-4.2).
1107  return !isset($path[0]) || '/' === $path[0]
1108  || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
1109  ? "./$path" : $path;
1110  }
1111 
1120  public function getQueryString()
1121  {
1122  $qs = static::normalizeQueryString($this->server->get('QUERY_STRING'));
1123 
1124  return '' === $qs ? null : $qs;
1125  }
1126 
1137  public function isSecure()
1138  {
1139  if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_X_FORWARDED_PROTO)) {
1140  return \in_array(strtolower($proto[0]), ['https', 'on', 'ssl', '1'], true);
1141  }
1143  $https = $this->server->get('HTTPS');
1144 
1145  return !empty($https) && 'off' !== strtolower($https);
1146  }
1147 
1160  public function getHost()
1161  {
1162  if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_X_FORWARDED_HOST)) {
1163  $host = $host[0];
1164  } elseif (!$host = $this->headers->get('HOST')) {
1165  if (!$host = $this->server->get('SERVER_NAME')) {
1166  $host = $this->server->get('SERVER_ADDR', '');
1167  }
1168  }
1169 
1170  // trim and remove port number from host
1171  // host is lowercase as per RFC 952/2181
1172  $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));
1173 
1174  // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user)
1175  // check that it does not contain forbidden characters (see RFC 952 and RFC 2181)
1176  // use preg_replace() instead of preg_match() to prevent DoS attacks with long host names
1177  if ($host && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) {
1178  if (!$this->isHostValid) {
1179  return '';
1180  }
1181  $this->isHostValid = false;
1182 
1183  throw new SuspiciousOperationException(sprintf('Invalid Host "%s".', $host));
1184  }
1185 
1186  if (\count(self::$trustedHostPatterns) > 0) {
1187  // to avoid host header injection attacks, you should provide a list of trusted host patterns
1188 
1189  if (\in_array($host, self::$trustedHosts)) {
1190  return $host;
1191  }
1192 
1193  foreach (self::$trustedHostPatterns as $pattern) {
1194  if (preg_match($pattern, $host)) {
1195  self::$trustedHosts[] = $host;
1196 
1197  return $host;
1198  }
1199  }
1200 
1201  if (!$this->isHostValid) {
1202  return '';
1203  }
1204  $this->isHostValid = false;
1205 
1206  throw new SuspiciousOperationException(sprintf('Untrusted Host "%s".', $host));
1207  }
1208 
1209  return $host;
1210  }
1211 
1217  public function setMethod($method)
1218  {
1219  $this->method = null;
1220  $this->server->set('REQUEST_METHOD', $method);
1221  }
1222 
1238  public function getMethod()
1239  {
1240  if (null !== $this->method) {
1241  return $this->method;
1242  }
1243 
1244  $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
1245 
1246  if ('POST' !== $this->method) {
1247  return $this->method;
1248  }
1249 
1250  $method = $this->headers->get('X-HTTP-METHOD-OVERRIDE');
1251 
1252  if (!$method && self::$httpMethodParameterOverride) {
1253  $method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1254  }
1255 
1256  if (!\is_string($method)) {
1257  return $this->method;
1258  }
1259 
1260  $method = strtoupper($method);
1261 
1262  if (\in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
1263  return $this->method = $method;
1264  }
1265 
1266  if (!preg_match('/^[A-Z]++$/D', $method)) {
1267  throw new SuspiciousOperationException(sprintf('Invalid method override "%s".', $method));
1268  }
1269 
1270  return $this->method = $method;
1271  }
1272 
1280  public function getRealMethod()
1281  {
1282  return strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
1283  }
1284 
1292  public function getMimeType($format)
1293  {
1294  if (null === static::$formats) {
1295  static::initializeFormats();
1296  }
1297 
1298  return isset(static::$formats[$format]) ? static::$formats[$format][0] : null;
1299  }
1300 
1308  public static function getMimeTypes($format)
1309  {
1310  if (null === static::$formats) {
1311  static::initializeFormats();
1312  }
1313 
1314  return isset(static::$formats[$format]) ? static::$formats[$format] : [];
1315  }
1316 
1324  public function getFormat($mimeType)
1325  {
1326  $canonicalMimeType = null;
1327  if (false !== $pos = strpos($mimeType, ';')) {
1328  $canonicalMimeType = trim(substr($mimeType, 0, $pos));
1329  }
1330 
1331  if (null === static::$formats) {
1332  static::initializeFormats();
1333  }
1334 
1335  foreach (static::$formats as $format => $mimeTypes) {
1336  if (\in_array($mimeType, (array) $mimeTypes)) {
1337  return $format;
1338  }
1339  if (null !== $canonicalMimeType && \in_array($canonicalMimeType, (array) $mimeTypes)) {
1340  return $format;
1341  }
1342  }
1343 
1344  return null;
1345  }
1353  public function setFormat($format, $mimeTypes)
1354  {
1355  if (null === static::$formats) {
1356  static::initializeFormats();
1357  }
1359  static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : [$mimeTypes];
1360  }
1361 
1377  public function getRequestFormat($default = 'html')
1378  {
1379  if (null === $this->format) {
1380  $this->format = $this->attributes->get('_format');
1381  }
1382 
1383  return null === $this->format ? $default : $this->format;
1384  }
1385 
1391  public function setRequestFormat($format)
1392  {
1393  $this->format = $format;
1394  }
1395 
1401  public function getContentType()
1402  {
1403  return $this->getFormat($this->headers->get('CONTENT_TYPE'));
1404  }
1405 
1411  public function setDefaultLocale($locale)
1412  {
1413  $this->defaultLocale = $locale;
1414 
1415  if (null === $this->locale) {
1416  $this->setPhpDefaultLocale($locale);
1417  }
1418  }
1425  public function getDefaultLocale()
1426  {
1427  return $this->defaultLocale;
1428  }
1429 
1435  public function setLocale($locale)
1436  {
1437  $this->setPhpDefaultLocale($this->locale = $locale);
1438  }
1439 
1445  public function getLocale()
1446  {
1447  return null === $this->locale ? $this->defaultLocale : $this->locale;
1448  }
1449 
1457  public function isMethod($method)
1458  {
1459  return $this->getMethod() === strtoupper($method);
1460  }
1461 
1469  public function isMethodSafe()
1470  {
1471  if (\func_num_args() > 0) {
1472  @trigger_error(sprintf('Passing arguments to "%s()" has been deprecated since Symfony 4.4; use "%s::isMethodCacheable()" to check if the method is cacheable instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED);
1473  }
1474 
1475  return \in_array($this->getMethod(), ['GET', 'HEAD', 'OPTIONS', 'TRACE']);
1476  }
1483  public function isMethodIdempotent()
1484  {
1485  return \in_array($this->getMethod(), ['HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE']);
1486  }
1487 
1495  public function isMethodCacheable()
1496  {
1497  return \in_array($this->getMethod(), ['GET', 'HEAD']);
1498  }
1499 
1511  public function getProtocolVersion()
1512  {
1513  if ($this->isFromTrustedProxy()) {
1514  preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
1515 
1516  if ($matches) {
1517  return 'HTTP/'.$matches[2];
1518  }
1519  }
1520 
1521  return $this->server->get('SERVER_PROTOCOL');
1522  }
1533  public function getContent($asResource = false)
1534  {
1535  $currentContentIsResource = \is_resource($this->content);
1536 
1537  if (true === $asResource) {
1538  if ($currentContentIsResource) {
1539  rewind($this->content);
1540 
1541  return $this->content;
1542  }
1543 
1544  // Content passed in parameter (test)
1545  if (\is_string($this->content)) {
1546  $resource = fopen('php://temp', 'r+');
1547  fwrite($resource, $this->content);
1548  rewind($resource);
1550  return $resource;
1551  }
1552 
1553  $this->content = false;
1554 
1555  return fopen('php://input', 'rb');
1556  }
1557 
1558  if ($currentContentIsResource) {
1559  rewind($this->content);
1560 
1561  return stream_get_contents($this->content);
1562  }
1563 
1564  if (null === $this->content || false === $this->content) {
1565  $this->content = file_get_contents('php://input');
1566  }
1567 
1568  return $this->content;
1569  }
1570 
1576  public function getETags()
1577  {
1578  return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY);
1579  }
1580 
1584  public function isNoCache()
1585  {
1586  return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma');
1587  }
1588 
1597  public function getPreferredFormat(?string $default = 'html'): ?string
1598  {
1599  if (null !== $this->preferredFormat || null !== $this->preferredFormat = $this->getRequestFormat(null)) {
1600  return $this->preferredFormat;
1601  }
1602 
1603  foreach ($this->getAcceptableContentTypes() as $mimeType) {
1604  if ($this->preferredFormat = $this->getFormat($mimeType)) {
1605  return $this->preferredFormat;
1606  }
1607  }
1608 
1609  return $default;
1610  }
1611 
1619  public function getPreferredLanguage(array $locales = null)
1620  {
1621  $preferredLanguages = $this->getLanguages();
1622 
1623  if (empty($locales)) {
1624  return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null;
1625  }
1626 
1627  if (!$preferredLanguages) {
1628  return $locales[0];
1629  }
1630 
1631  $extendedPreferredLanguages = [];
1632  foreach ($preferredLanguages as $language) {
1633  $extendedPreferredLanguages[] = $language;
1634  if (false !== $position = strpos($language, '_')) {
1635  $superLanguage = substr($language, 0, $position);
1636  if (!\in_array($superLanguage, $preferredLanguages)) {
1637  $extendedPreferredLanguages[] = $superLanguage;
1638  }
1639  }
1640  }
1641 
1642  $preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
1643 
1644  return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
1645  }
1646 
1652  public function getLanguages()
1653  {
1654  if (null !== $this->languages) {
1655  return $this->languages;
1656  }
1657 
1658  $languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all();
1659  $this->languages = [];
1660  foreach ($languages as $lang => $acceptHeaderItem) {
1661  if (false !== strpos($lang, '-')) {
1662  $codes = explode('-', $lang);
1663  if ('i' === $codes[0]) {
1664  // Language not listed in ISO 639 that are not variants
1665  // of any listed language, which can be registered with the
1666  // i-prefix, such as i-cherokee
1667  if (\count($codes) > 1) {
1668  $lang = $codes[1];
1669  }
1670  } else {
1671  for ($i = 0, $max = \count($codes); $i < $max; ++$i) {
1672  if (0 === $i) {
1673  $lang = strtolower($codes[0]);
1674  } else {
1675  $lang .= '_'.strtoupper($codes[$i]);
1676  }
1677  }
1678  }
1679  }
1680 
1681  $this->languages[] = $lang;
1682  }
1683 
1684  return $this->languages;
1685  }
1686 
1692  public function getCharsets()
1693  {
1694  if (null !== $this->charsets) {
1695  return $this->charsets;
1696  }
1697 
1698  return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
1699  }
1700 
1706  public function getEncodings()
1707  {
1708  if (null !== $this->encodings) {
1709  return $this->encodings;
1710  }
1711 
1712  return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all());
1713  }
1714 
1720  public function getAcceptableContentTypes()
1721  {
1722  if (null !== $this->acceptableContentTypes) {
1724  }
1725 
1726  return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all());
1727  }
1728 
1739  public function isXmlHttpRequest()
1740  {
1741  return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
1742  }
1743 
1744  /*
1745  * The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24)
1746  *
1747  * Code subject to the new BSD license (https://framework.zend.com/license).
1748  *
1749  * Copyright (c) 2005-2010 Zend Technologies USA Inc. (https://www.zend.com/)
1750  */
1751 
1752  protected function prepareRequestUri()
1753  {
1754  $requestUri = '';
1755 
1756  if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
1757  // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
1758  $requestUri = $this->server->get('UNENCODED_URL');
1759  $this->server->remove('UNENCODED_URL');
1760  $this->server->remove('IIS_WasUrlRewritten');
1761  } elseif ($this->server->has('REQUEST_URI')) {
1762  $requestUri = $this->server->get('REQUEST_URI');
1763 
1764  if ('' !== $requestUri && '/' === $requestUri[0]) {
1765  // To only use path and query remove the fragment.
1766  if (false !== $pos = strpos($requestUri, '#')) {
1767  $requestUri = substr($requestUri, 0, $pos);
1768  }
1769  } else {
1770  // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
1771  // only use URL path.
1772  $uriComponents = parse_url($requestUri);
1773 
1774  if (isset($uriComponents['path'])) {
1775  $requestUri = $uriComponents['path'];
1776  }
1777 
1778  if (isset($uriComponents['query'])) {
1779  $requestUri .= '?'.$uriComponents['query'];
1780  }
1781  }
1782  } elseif ($this->server->has('ORIG_PATH_INFO')) {
1783  // IIS 5.0, PHP as CGI
1784  $requestUri = $this->server->get('ORIG_PATH_INFO');
1785  if ('' != $this->server->get('QUERY_STRING')) {
1786  $requestUri .= '?'.$this->server->get('QUERY_STRING');
1787  }
1788  $this->server->remove('ORIG_PATH_INFO');
1789  }
1790 
1791  // normalize the request URI to ease creating sub-requests from this request
1792  $this->server->set('REQUEST_URI', $requestUri);
1793 
1794  return $requestUri;
1795  }
1796 
1802  protected function prepareBaseUrl()
1803  {
1804  $filename = basename($this->server->get('SCRIPT_FILENAME'));
1806  if (basename($this->server->get('SCRIPT_NAME')) === $filename) {
1807  $baseUrl = $this->server->get('SCRIPT_NAME');
1808  } elseif (basename($this->server->get('PHP_SELF')) === $filename) {
1809  $baseUrl = $this->server->get('PHP_SELF');
1810  } elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) {
1811  $baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility
1812  } else {
1813  // Backtrack up the script_filename to find the portion matching
1814  // php_self
1815  $path = $this->server->get('PHP_SELF', '');
1816  $file = $this->server->get('SCRIPT_FILENAME', '');
1817  $segs = explode('/', trim($file, '/'));
1818  $segs = array_reverse($segs);
1819  $index = 0;
1820  $last = \count($segs);
1821  $baseUrl = '';
1822  do {
1823  $seg = $segs[$index];
1824  $baseUrl = '/'.$seg.$baseUrl;
1825  ++$index;
1826  } while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos);
1827  }
1828 
1829  // Does the baseUrl have anything in common with the request_uri?
1830  $requestUri = $this->getRequestUri();
1831  if ('' !== $requestUri && '/' !== $requestUri[0]) {
1832  $requestUri = '/'.$requestUri;
1833  }
1834 
1835  if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
1836  // full $baseUrl matches
1837  return $prefix;
1838  }
1839 
1840  if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
1841  // directory portion of $baseUrl matches
1842  return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
1843  }
1844 
1845  $truncatedRequestUri = $requestUri;
1846  if (false !== $pos = strpos($requestUri, '?')) {
1847  $truncatedRequestUri = substr($requestUri, 0, $pos);
1848  }
1849 
1850  $basename = basename($baseUrl);
1851  if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1852  // no match whatsoever; set it blank
1853  return '';
1854  }
1855 
1856  // If using mod_rewrite or ISAPI_Rewrite strip the script filename
1857  // out of baseUrl. $pos !== 0 makes sure it is not matching a value
1858  // from PATH_INFO or QUERY_STRING
1859  if (\strlen($requestUri) >= \strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
1860  $baseUrl = substr($requestUri, 0, $pos + \strlen($baseUrl));
1861  }
1862 
1863  return rtrim($baseUrl, '/'.\DIRECTORY_SEPARATOR);
1864  }
1865 
1871  protected function prepareBasePath()
1872  {
1873  $baseUrl = $this->getBaseUrl();
1874  if (empty($baseUrl)) {
1875  return '';
1876  }
1877 
1878  $filename = basename($this->server->get('SCRIPT_FILENAME'));
1879  if (basename($baseUrl) === $filename) {
1880  $basePath = \dirname($baseUrl);
1881  } else {
1882  $basePath = $baseUrl;
1883  }
1884 
1885  if ('\\' === \DIRECTORY_SEPARATOR) {
1886  $basePath = str_replace('\\', '/', $basePath);
1887  }
1888 
1889  return rtrim($basePath, '/');
1890  }
1891 
1897  protected function preparePathInfo()
1898  {
1899  if (null === ($requestUri = $this->getRequestUri())) {
1900  return '/';
1901  }
1902 
1903  // Remove the query string from REQUEST_URI
1904  if (false !== $pos = strpos($requestUri, '?')) {
1905  $requestUri = substr($requestUri, 0, $pos);
1906  }
1907  if ('' !== $requestUri && '/' !== $requestUri[0]) {
1908  $requestUri = '/'.$requestUri;
1909  }
1910 
1911  if (null === ($baseUrl = $this->getBaseUrl())) {
1912  return $requestUri;
1913  }
1914 
1915  $pathInfo = substr($requestUri, \strlen($baseUrl));
1916  if (false === $pathInfo || '' === $pathInfo) {
1917  // If substr() returns false then PATH_INFO is set to an empty string
1918  return '/';
1919  }
1920 
1921  return (string) $pathInfo;
1922  }
1923 
1927  protected static function initializeFormats()
1928  {
1929  static::$formats = [
1930  'html' => ['text/html', 'application/xhtml+xml'],
1931  'txt' => ['text/plain'],
1932  'js' => ['application/javascript', 'application/x-javascript', 'text/javascript'],
1933  'css' => ['text/css'],
1934  'json' => ['application/json', 'application/x-json'],
1935  'jsonld' => ['application/ld+json'],
1936  'xml' => ['text/xml', 'application/xml', 'application/x-xml'],
1937  'rdf' => ['application/rdf+xml'],
1938  'atom' => ['application/atom+xml'],
1939  'rss' => ['application/rss+xml'],
1940  'form' => ['application/x-www-form-urlencoded'],
1941  ];
1942  }
1943 
1944  private function setPhpDefaultLocale(string $locale): void
1945  {
1946  // if either the class Locale doesn't exist, or an exception is thrown when
1947  // setting the default locale, the intl module is not installed, and
1948  // the call can be ignored:
1949  try {
1950  if (class_exists('Locale', false)) {
1951  \Locale::setDefault($locale);
1952  }
1953  } catch (\Exception $e) {
1954  }
1955  }
1956 
1961  private function getUrlencodedPrefix(string $string, string $prefix): ?string
1962  {
1963  if (0 !== strpos(rawurldecode($string), $prefix)) {
1964  return null;
1965  }
1966 
1967  $len = \strlen($prefix);
1968 
1969  if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) {
1970  return $match[0];
1971  }
1972 
1973  return null;
1974  }
1975 
1976  private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): self
1977  {
1978  if (self::$requestFactory) {
1980 
1981  if (!$request instanceof self) {
1982  throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
1983  }
1984 
1985  return $request;
1986  }
1987 
1988  return new static($query, $request, $attributes, $cookies, $files, $server, $content);
1989  }
1990 
1999  public function isFromTrustedProxy()
2000  {
2001  return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
2002  }
2003 
2004  private function getTrustedValues(int $type, string $ip = null): array
2005  {
2006  $clientValues = [];
2007  $forwardedValues = [];
2008 
2009  if ((self::$trustedHeaderSet & $type) && $this->headers->has(self::$trustedHeaders[$type])) {
2010  foreach (explode(',', $this->headers->get(self::$trustedHeaders[$type])) as $v) {
2011  $clientValues[] = (self::HEADER_X_FORWARDED_PORT === $type ? '0.0.0.0:' : '').trim($v);
2012  }
2013  }
2014 
2015  if ((self::$trustedHeaderSet & self::HEADER_FORWARDED) && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) {
2016  $forwarded = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]);
2017  $parts = HeaderUtils::split($forwarded, ',;=');
2018  $forwardedValues = [];
2019  $param = self::$forwardedParams[$type];
2020  foreach ($parts as $subParts) {
2021  if (null === $v = HeaderUtils::combine($subParts)[$param] ?? null) {
2022  continue;
2023  }
2024  if (self::HEADER_X_FORWARDED_PORT === $type) {
2025  if (']' === substr($v, -1) || false === $v = strrchr($v, ':')) {
2026  $v = $this->isSecure() ? ':443' : ':80';
2027  }
2028  $v = '0.0.0.0'.$v;
2029  }
2030  $forwardedValues[] = $v;
2031  }
2032  }
2033 
2034  if (null !== $ip) {
2035  $clientValues = $this->normalizeAndFilterClientIps($clientValues, $ip);
2036  $forwardedValues = $this->normalizeAndFilterClientIps($forwardedValues, $ip);
2037  }
2038 
2039  if ($forwardedValues === $clientValues || !$clientValues) {
2040  return $forwardedValues;
2041  }
2042 
2043  if (!$forwardedValues) {
2044  return $clientValues;
2045  }
2046 
2047  if (!$this->isForwardedValid) {
2048  return null !== $ip ? ['0.0.0.0', $ip] : [];
2049  }
2050  $this->isForwardedValid = false;
2051 
2052  throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type]));
2053  }
2054 
2055  private function normalizeAndFilterClientIps(array $clientIps, string $ip): array
2056  {
2057  if (!$clientIps) {
2058  return [];
2059  }
2060  $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
2061  $firstTrustedIp = null;
2062 
2063  foreach ($clientIps as $key => $clientIp) {
2064  if (strpos($clientIp, '.')) {
2065  // Strip :port from IPv4 addresses. This is allowed in Forwarded
2066  // and may occur in X-Forwarded-For.
2067  $i = strpos($clientIp, ':');
2068  if ($i) {
2069  $clientIps[$key] = $clientIp = substr($clientIp, 0, $i);
2070  }
2071  } elseif (0 === strpos($clientIp, '[')) {
2072  // Strip brackets and :port from IPv6 addresses.
2073  $i = strpos($clientIp, ']', 1);
2074  $clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1);
2075  }
2076 
2077  if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
2078  unset($clientIps[$key]);
2079 
2080  continue;
2081  }
2082 
2083  if (IpUtils::checkIp($clientIp, self::$trustedProxies)) {
2084  unset($clientIps[$key]);
2085 
2086  // Fallback to this when the client IP falls into the range of trusted proxies
2087  if (null === $firstTrustedIp) {
2088  $firstTrustedIp = $clientIp;
2089  }
2090  }
2091  }
2092 
2093  // Now the IP chain contains only untrusted proxies and the client IP
2094  return $clientIps ? array_reverse($clientIps) : [$firstTrustedIp];
2095  }
2096 }
Symfony\Component\HttpFoundation\Request\initialize
initialize(array $query=[], array $request=[], array $attributes=[], array $cookies=[], array $files=[], array $server=[], $content=null)
Definition: vendor/symfony/http-foundation/Request.php:329
Symfony\Component\HttpFoundation\ServerBag
Definition: lib/vendor/symfony/http-foundation/ServerBag.php:21
Symfony\Component\HttpFoundation\Request\getLocale
getLocale()
Definition: vendor/symfony/http-foundation/Request.php:1511
Symfony\Component\HttpFoundation\Request\$encodings
$encodings
Definition: lib/vendor/symfony/http-foundation/Request.php:197
Symfony\Component\HttpFoundation\Request\$languages
$languages
Definition: lib/vendor/symfony/http-foundation/Request.php:181
Symfony\Component\HttpFoundation\Request\enableHttpMethodParameterOverride
static enableHttpMethodParameterOverride()
Definition: vendor/symfony/http-foundation/Request.php:742
Symfony\Component\HttpFoundation\Request\METHOD_DELETE
const METHOD_DELETE
Definition: lib/vendor/symfony/http-foundation/Request.php:55
Symfony\Component\HttpFoundation\Request\__clone
__clone()
Definition: vendor/symfony/http-foundation/Request.php:555
Symfony\Component\HttpFoundation\Request\METHOD_PATCH
const METHOD_PATCH
Definition: lib/vendor/symfony/http-foundation/Request.php:54
Symfony\Component\HttpFoundation\Request\$httpMethodParameterOverride
static $httpMethodParameterOverride
Definition: lib/vendor/symfony/http-foundation/Request.php:96
Symfony\Component\HttpFoundation\HeaderUtils\combine
static combine(array $parts)
Definition: HeaderUtils.php:83
Symfony\Component\HttpFoundation\Request\getSchemeAndHttpHost
getSchemeAndHttpHost()
Definition: vendor/symfony/http-foundation/Request.php:1090
Symfony\Component\HttpFoundation\Request\METHOD_CONNECT
const METHOD_CONNECT
Definition: lib/vendor/symfony/http-foundation/Request.php:59
Symfony\Component\HttpFoundation\Request\getClientIp
getClientIp()
Definition: vendor/symfony/http-foundation/Request.php:889
Symfony\Component\HttpFoundation\Request\getHttpHost
getHttpHost()
Definition: vendor/symfony/http-foundation/Request.php:1056
Symfony\Component\HttpFoundation\Request\$trustedProxies
static $trustedProxies
Definition: lib/vendor/symfony/http-foundation/Request.php:65
Symfony\Component\HttpFoundation\Request\METHOD_TRACE
const METHOD_TRACE
Definition: lib/vendor/symfony/http-foundation/Request.php:58
Symfony\Component\HttpFoundation\Request\getProtocolVersion
getProtocolVersion()
Definition: vendor/symfony/http-foundation/Request.php:1577
Symfony\Component\HttpFoundation\Request\isMethodIdempotent
isMethodIdempotent()
Definition: vendor/symfony/http-foundation/Request.php:1549
Symfony\Component\HttpFoundation\Request\getDefaultLocale
getDefaultLocale()
Definition: vendor/symfony/http-foundation/Request.php:1491
Symfony\Component\HttpFoundation\Request\setSession
setSession(SessionInterface $session)
Definition: lib/vendor/symfony/http-foundation/Request.php:927
Symfony\Component\HttpFoundation\Request\setFactory
static setFactory($callable)
Definition: vendor/symfony/http-foundation/Request.php:488
Symfony\Component\HttpFoundation\Request\getUser
getUser()
Definition: vendor/symfony/http-foundation/Request.php:1017
Symfony\Component\HttpFoundation\Request\$trustedHostPatterns
static $trustedHostPatterns
Definition: lib/vendor/symfony/http-foundation/Request.php:70
Symfony\Component\HttpFoundation\Request\isMethodSafe
isMethodSafe()
Definition: vendor/symfony/http-foundation/Request.php:1535
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_FOR
const HEADER_X_FORWARDED_FOR
Definition: lib/vendor/symfony/http-foundation/Request.php:34
Symfony\Component\HttpFoundation\IpUtils\checkIp
static checkIp($requestIp, $ips)
Definition: lib/vendor/symfony/http-foundation/IpUtils.php:38
Symfony\Component\HttpFoundation\Request\setSessionFactory
setSessionFactory(callable $factory)
Definition: vendor/symfony/http-foundation/Request.php:842
Symfony\Component\HttpFoundation\Request\HEADER_FORWARDED
const HEADER_FORWARDED
Definition: lib/vendor/symfony/http-foundation/Request.php:33
Symfony\Component\HttpFoundation\Request\__construct
__construct(array $query=[], array $request=[], array $attributes=[], array $cookies=[], array $files=[], array $server=[], $content=null)
Definition: vendor/symfony/http-foundation/Request.php:311
Symfony\Component\HttpFoundation\Request\$session
$session
Definition: lib/vendor/symfony/http-foundation/Request.php:261
Symfony\Component\HttpFoundation\Request\$requestFactory
static $requestFactory
Definition: lib/vendor/symfony/http-foundation/Request.php:284
Symfony\Component\HttpFoundation\Request\getEncodings
getEncodings()
Definition: vendor/symfony/http-foundation/Request.php:1772
Symfony\Component\HttpFoundation\Request\getPathInfo
getPathInfo()
Definition: vendor/symfony/http-foundation/Request.php:920
Symfony\Component\HttpFoundation\Request\getTrustedProxies
static getTrustedProxies()
Definition: vendor/symfony/http-foundation/Request.php:668
Symfony\Component\HttpFoundation\Request\isNoCache
isNoCache()
Definition: vendor/symfony/http-foundation/Request.php:1650
Symfony\Component\HttpFoundation\Request\getClientIps
getClientIps()
Definition: vendor/symfony/http-foundation/Request.php:860
Symfony\Component\HttpFoundation\Request\create
static create($uri, $method='GET', $parameters=[], $cookies=[], $files=[], $server=[], $content=null)
Definition: vendor/symfony/http-foundation/Request.php:387
Symfony\Component\HttpFoundation\Request\$method
$method
Definition: lib/vendor/symfony/http-foundation/Request.php:245
Symfony\Component\HttpFoundation\Request\$content
$content
Definition: lib/vendor/symfony/http-foundation/Request.php:173
Symfony\Component\HttpFoundation\Request\getBasePath
getBasePath()
Definition: vendor/symfony/http-foundation/Request.php:941
Symfony\Component\HttpFoundation\Request\getUserInfo
getUserInfo()
Definition: vendor/symfony/http-foundation/Request.php:1037
Symfony\Component\HttpFoundation\Request\$requestUri
$requestUri
Definition: lib/vendor/symfony/http-foundation/Request.php:221
Symfony\Component\HttpFoundation\Request\getContentType
getContentType()
Definition: vendor/symfony/http-foundation/Request.php:1467
Symfony\Component\HttpFoundation\Request\METHOD_POST
const METHOD_POST
Definition: lib/vendor/symfony/http-foundation/Request.php:52
Symfony\Component\HttpFoundation\Request\getMethod
getMethod()
Definition: lib/vendor/symfony/http-foundation/Request.php:1401
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_ALL
const HEADER_X_FORWARDED_ALL
Definition: lib/vendor/symfony/http-foundation/Request.php:38
Symfony\Component\HttpFoundation\Request\getPreferredLanguage
getPreferredLanguage(array $locales=null)
Definition: vendor/symfony/http-foundation/Request.php:1685
Symfony\Component\HttpFoundation\Request\$files
$files
Definition: lib/vendor/symfony/http-foundation/Request.php:145
Symfony\Component\HttpFoundation\Request\setMethod
setMethod($method)
Definition: vendor/symfony/http-foundation/Request.php:1283
Symfony\Component\HttpFoundation\AcceptHeader\fromString
static fromString($headerValue)
Definition: lib/vendor/symfony/http-foundation/AcceptHeader.php:59
Symfony\Component\HttpFoundation\Request\METHOD_GET
const METHOD_GET
Definition: lib/vendor/symfony/http-foundation/Request.php:51
Symfony\Component\HttpFoundation\Session\SessionInterface
Definition: lib/vendor/symfony/http-foundation/Session/SessionInterface.php:21
Symfony\Component\HttpFoundation\Request\METHOD_OPTIONS
const METHOD_OPTIONS
Definition: lib/vendor/symfony/http-foundation/Request.php:57
Symfony\Component\HttpFoundation\Request\$format
$format
Definition: lib/vendor/symfony/http-foundation/Request.php:253
Symfony\Component\HttpFoundation\Request\$trustedHosts
static $trustedHosts
Definition: lib/vendor/symfony/http-foundation/Request.php:75
Symfony\Component\HttpFoundation\Request\prepareRequestUri
prepareRequestUri()
Definition: lib/vendor/symfony/http-foundation/Request.php:1855
Symfony\Component\HttpFoundation\Request\$formats
static $formats
Definition: lib/vendor/symfony/http-foundation/Request.php:282
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_PROTO
const HEADER_X_FORWARDED_PROTO
Definition: lib/vendor/symfony/http-foundation/Request.php:36
Symfony\Component\HttpFoundation\Request\getTrustedHosts
static getTrustedHosts()
Definition: vendor/symfony/http-foundation/Request.php:704
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_PORT
const HEADER_X_FORWARDED_PORT
Definition: lib/vendor/symfony/http-foundation/Request.php:37
Symfony\Component\HttpFoundation\Request\initialize
initialize(array $query=array(), array $request=array(), array $attributes=array(), array $cookies=array(), array $files=array(), array $server=array(), $content=null)
Definition: lib/vendor/symfony/http-foundation/Request.php:337
Symfony\Component\HttpFoundation\Request\$acceptableContentTypes
$acceptableContentTypes
Definition: lib/vendor/symfony/http-foundation/Request.php:205
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_AWS_ELB
const HEADER_X_FORWARDED_AWS_ELB
Definition: lib/vendor/symfony/http-foundation/Request.php:39
Symfony\Component\HttpFoundation\Request\isSecure
isSecure()
Definition: lib/vendor/symfony/http-foundation/Request.php:1296
Symfony\Component\HttpFoundation\Request\$server
$server
Definition: lib/vendor/symfony/http-foundation/Request.php:135
Symfony\Component\HttpFoundation\Request\getContent
getContent($asResource=false)
Definition: lib/vendor/symfony/http-foundation/Request.php:1656
Symfony\Component\HttpFoundation\Request\preparePathInfo
preparePathInfo()
Definition: lib/vendor/symfony/http-foundation/Request.php:1994
Symfony\Component\HttpFoundation\Request\setTrustedProxies
static setTrustedProxies(array $proxies)
Definition: lib/vendor/symfony/http-foundation/Request.php:651
Symfony\Component\HttpFoundation\Request\__toString
__toString()
Definition: vendor/symfony/http-foundation/Request.php:571
Symfony\Component\HttpFoundation\Request\$baseUrl
$baseUrl
Definition: lib/vendor/symfony/http-foundation/Request.php:229
Symfony\Component\HttpFoundation\Request\setLocale
setLocale($locale)
Definition: vendor/symfony/http-foundation/Request.php:1501
Symfony\Component\HttpFoundation\Request\hasSession
hasSession()
Definition: lib/vendor/symfony/http-foundation/Request.php:917
Symfony\Component\HttpFoundation\Request\setFormat
setFormat($format, $mimeTypes)
Definition: vendor/symfony/http-foundation/Request.php:1419
Symfony\Component\HttpFoundation\Request\getHttpMethodParameterOverride
static getHttpMethodParameterOverride()
Definition: vendor/symfony/http-foundation/Request.php:752
Symfony\Component\HttpFoundation\ParameterBag
Definition: lib/vendor/symfony/http-foundation/ParameterBag.php:19
Symfony\Component\HttpFoundation\Request\getAcceptableContentTypes
getAcceptableContentTypes()
Definition: lib/vendor/symfony/http-foundation/Request.php:1823
Symfony\Component\HttpFoundation\Request\initializeFormats
static initializeFormats()
Definition: vendor/symfony/http-foundation/Request.php:1993
Symfony\Component\HttpFoundation\Request\$query
$query
Definition: lib/vendor/symfony/http-foundation/Request.php:125
Symfony\Component\HttpFoundation\Request\getRealMethod
getRealMethod()
Definition: vendor/symfony/http-foundation/Request.php:1346
Symfony\Component\HttpFoundation\Request\normalizeQueryString
static normalizeQueryString($qs)
Definition: vendor/symfony/http-foundation/Request.php:719
Symfony\Component\HttpFoundation\Request\getMimeTypes
static getMimeTypes($format)
Definition: vendor/symfony/http-foundation/Request.php:1374
Symfony\Component\HttpFoundation\Request\prepareBaseUrl
prepareBaseUrl()
Definition: lib/vendor/symfony/http-foundation/Request.php:1902
Symfony\Component\HttpFoundation\Request\getQueryString
getQueryString()
Definition: lib/vendor/symfony/http-foundation/Request.php:1275
Symfony\Component\HttpFoundation\Request\getBaseUrl
getBaseUrl()
Definition: vendor/symfony/http-foundation/Request.php:960
Symfony\Component\HttpFoundation\Request\createFromGlobals
static createFromGlobals()
Definition: vendor/symfony/http-foundation/Request.php:357
Symfony\Component\HttpFoundation\Request\$trustedHeaders
static $trustedHeaders
Definition: lib/vendor/symfony/http-foundation/Request.php:88
Request
Mock implementation of the Request class.
Definition: Request.inc.php:21
Symfony\Component\HttpFoundation\Request\HEADER_X_FORWARDED_HOST
const HEADER_X_FORWARDED_HOST
Definition: lib/vendor/symfony/http-foundation/Request.php:35
Symfony\Component\HttpFoundation\Request\getPreferredFormat
getPreferredFormat(?string $default='html')
Definition: vendor/symfony/http-foundation/Request.php:1663
Symfony\Component\HttpFoundation\Request\prepareBasePath
prepareBasePath()
Definition: lib/vendor/symfony/http-foundation/Request.php:1968
Symfony\Component\HttpFoundation\Request\isFromTrustedProxy
isFromTrustedProxy()
Definition: lib/vendor/symfony/http-foundation/Request.php:2102
Symfony\Component\HttpFoundation\Request\$locale
$locale
Definition: lib/vendor/symfony/http-foundation/Request.php:269
Symfony\Component\HttpFoundation\Request\getCharsets
getCharsets()
Definition: vendor/symfony/http-foundation/Request.php:1758
Symfony\Component\HttpFoundation\Request\getPort
getPort()
Definition: vendor/symfony/http-foundation/Request.php:989
Symfony\Component\HttpFoundation\Request\METHOD_HEAD
const METHOD_HEAD
Definition: lib/vendor/symfony/http-foundation/Request.php:50
Symfony\Component\HttpFoundation\Request\$pathInfo
$pathInfo
Definition: lib/vendor/symfony/http-foundation/Request.php:213
Symfony\Component\HttpFoundation
Definition: lib/vendor/symfony/http-foundation/AcceptHeader.php:12
Symfony\Component\HttpFoundation\Request\duplicate
duplicate(array $query=null, array $request=null, array $attributes=null, array $cookies=null, array $files=null, array $server=null)
Definition: vendor/symfony/http-foundation/Request.php:505
Symfony\Component\HttpFoundation\Request\getScheme
getScheme()
Definition: vendor/symfony/http-foundation/Request.php:974
Symfony\Component\HttpFoundation\FileBag
Definition: lib/vendor/symfony/http-foundation/FileBag.php:22
Symfony\Component\HttpFoundation\HeaderBag
Definition: lib/vendor/symfony/http-foundation/HeaderBag.php:19
Symfony\Component\HttpFoundation\Request\hasPreviousSession
hasPreviousSession()
Definition: vendor/symfony/http-foundation/Request.php:814
Symfony\Component\HttpFoundation\Request\getPassword
getPassword()
Definition: vendor/symfony/http-foundation/Request.php:1027
Symfony\Component\HttpFoundation\Request\overrideGlobals
overrideGlobals()
Definition: vendor/symfony/http-foundation/Request.php:607
Symfony\Component\HttpFoundation\HeaderUtils\split
static split(string $header, string $separators)
Definition: HeaderUtils.php:45
Symfony\Component\HttpFoundation\Request\getETags
getETags()
Definition: vendor/symfony/http-foundation/Request.php:1642
Symfony\Component\HttpFoundation\Request\__construct
__construct(array $query=array(), array $request=array(), array $attributes=array(), array $cookies=array(), array $files=array(), array $server=array(), $content=null)
Definition: lib/vendor/symfony/http-foundation/Request.php:319
Symfony\Component\HttpFoundation\Request\METHOD_PURGE
const METHOD_PURGE
Definition: lib/vendor/symfony/http-foundation/Request.php:56
Symfony\Component\HttpFoundation\Request\setDefaultLocale
setDefaultLocale($locale)
Definition: vendor/symfony/http-foundation/Request.php:1477
Symfony\Component\HttpFoundation\Request\$defaultLocale
$defaultLocale
Definition: lib/vendor/symfony/http-foundation/Request.php:277
Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
Definition: lib/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php:19
Symfony\Component\HttpFoundation\Request\getLanguages
getLanguages()
Definition: lib/vendor/symfony/http-foundation/Request.php:1755
Symfony\Component\HttpFoundation\Request\getFormat
getFormat($mimeType)
Definition: vendor/symfony/http-foundation/Request.php:1390
Symfony\Component\HttpFoundation\Request\getRequestFormat
getRequestFormat($default='html')
Definition: lib/vendor/symfony/http-foundation/Request.php:1518
Symfony\Component\HttpFoundation\Request\METHOD_PUT
const METHOD_PUT
Definition: lib/vendor/symfony/http-foundation/Request.php:53
Symfony\Component\HttpFoundation\Request\setRequestFormat
setRequestFormat($format)
Definition: vendor/symfony/http-foundation/Request.php:1457
Symfony\Component\HttpFoundation\Request\getScriptName
getScriptName()
Definition: vendor/symfony/http-foundation/Request.php:901
Symfony\Component\HttpFoundation\Request\getUri
getUri()
Definition: vendor/symfony/http-foundation/Request.php:1102
Symfony\Component\HttpFoundation\Request\getTrustedHeaderSet
static getTrustedHeaderSet()
Definition: vendor/symfony/http-foundation/Request.php:678
Symfony\Component\HttpFoundation\Request\getHost
getHost()
Definition: lib/vendor/symfony/http-foundation/Request.php:1323
Symfony\Component\HttpFoundation\Request\$basePath
$basePath
Definition: lib/vendor/symfony/http-foundation/Request.php:237
Symfony\Component\HttpFoundation\Request\getUriForPath
getUriForPath($path)
Definition: vendor/symfony/http-foundation/Request.php:1118
Symfony\Component\HttpFoundation\Request\$cookies
$cookies
Definition: lib/vendor/symfony/http-foundation/Request.php:155
Symfony\Component\HttpFoundation\Request\setTrustedProxies
static setTrustedProxies(array $proxies, int $trustedHeaderSet)
Definition: vendor/symfony/http-foundation/Request.php:649
Symfony\Component\HttpFoundation\Request\setTrustedHosts
static setTrustedHosts(array $hostPatterns)
Definition: vendor/symfony/http-foundation/Request.php:690
Symfony\Component\HttpFoundation\Request\$attributes
$attributes
Definition: lib/vendor/symfony/http-foundation/Request.php:105
Symfony\Component\HttpFoundation\Request\$headers
$headers
Definition: lib/vendor/symfony/http-foundation/Request.php:165
Symfony\Component\HttpFoundation\Request\$request
$request
Definition: lib/vendor/symfony/http-foundation/Request.php:115
Seboettg\CiteProc\Styles\format
format($text)
Definition: FormattingTrait.php:81
Symfony\Component\HttpFoundation\Request\getRelativeUriForPath
getRelativeUriForPath($path)
Definition: vendor/symfony/http-foundation/Request.php:1142
Symfony\Component\HttpFoundation\Request\getRequestUri
getRequestUri()
Definition: lib/vendor/symfony/http-foundation/Request.php:1162
Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException
Definition: lib/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php:18
Symfony\Component\HttpFoundation\Request\getSession
getSession()
Definition: vendor/symfony/http-foundation/Request.php:793
Symfony\Component\HttpFoundation\Request\$charsets
$charsets
Definition: lib/vendor/symfony/http-foundation/Request.php:189
Symfony\Component\HttpFoundation\Request\isXmlHttpRequest
isXmlHttpRequest()
Definition: vendor/symfony/http-foundation/Request.php:1805
Symfony\Component\HttpFoundation\Request\isMethod
isMethod($method)
Definition: vendor/symfony/http-foundation/Request.php:1523
Symfony\Component\HttpFoundation\Request\isMethodCacheable
isMethodCacheable()
Definition: vendor/symfony/http-foundation/Request.php:1561
Symfony\Component\HttpFoundation\Request\getMimeType
getMimeType($format)
Definition: vendor/symfony/http-foundation/Request.php:1358
Symfony\Component\HttpFoundation\Request\create
static create($uri, $method='GET', $parameters=array(), $cookies=array(), $files=array(), $server=array(), $content=null)
Definition: lib/vendor/symfony/http-foundation/Request.php:408