64 parent::__construct(
$server, $request);
71 $this->headers = $this->buildHttpHeaders(
$server);
78 foreach ($this->fetchHeaders(
$server) as $headerName => $value)
93 parent::addFilter($filter);
95 $filteredValues = $filter->filter([
96 'get' => $this->queryString->values,
97 'post' => $this->postData->values,
98 'files' => $this->files->values,
99 'cookie' => $this->cookiesRaw->values,
100 'json' => $this->jsonData->values,
103 if (isset($filteredValues[
'get']))
105 $this->queryString->setValuesNoDemand($filteredValues[
'get']);
107 if (isset($filteredValues[
'post']))
109 $this->postData->setValuesNoDemand($filteredValues[
'post']);
111 if (isset($filteredValues[
'files']))
113 $this->files->setValuesNoDemand($filteredValues[
'files']);
115 if (isset($filteredValues[
'cookie']))
117 $this->cookiesRaw->setValuesNoDemand($filteredValues[
'cookie']);
120 if (isset($filteredValues[
'json']))
122 $this->jsonData->setValuesNoDemand($filteredValues[
'json']);
125 if (isset($filteredValues[
'get']) || isset($filteredValues[
'post']))
127 $this->
setValuesNoDemand(array_merge($this->queryString->values, $this->postData->values));
139 return $this->queryString->get($name);
160 return $this->postData->get($name);
181 return $this->files->get($name);
203 return $this->headers->get($name);
224 return $this->cookies->get($name);
239 return $this->cookiesRaw->get($name);
254 return $this->server->get(
'REMOTE_ADDR');
263 return $this->server->get(
'HTTP_USER_AGENT');
268 return $this->server->getRequestUri();
273 return $this->server->getRequestMethod();
283 return $this->server->getServerPort();
293 if ($this->acceptedLanguages ===
null)
295 $this->acceptedLanguages = [];
300 $lang = explode(
';', $language);
301 $this->acceptedLanguages[] = $lang[0];
315 if ($this->requestedPage ===
null)
319 $this->requestedPage = parent::getRequestedPage();
323 $parsedUri =
new Web\Uri(
"http://" . $this->server->getHttpHost() . $uri);
324 $this->requestedPage = static::normalize(static::decode($parsedUri->getPath()));
337 $parsedUri =
new Web\Uri(
"http://" . $this->server->getHttpHost() . $this->getRequestUri());
339 $uri = static::decode($parsedUri->getPath());
341 if (($query = $parsedUri->getQuery()) !=
'')
343 $uri .=
"?" . $query;
351 return Text\Encoding::convertEncodingToCurrent(rawurldecode($url));
360 if ($this->httpHost ===
null)
363 $url =
new Web\Uri(
"http://" . $this->server->getHttpHost());
364 $host = $url->getHost();
365 $host = trim($host,
"\t\r\n\0 .");
367 $this->httpHost = $host;
375 if ($this->server->get(
"SERVER_PORT") == 443)
380 $https = $this->server->get(
"HTTPS");
381 if ($https !=
'' && strtolower($https) !=
"off")
388 return (
Config\Configuration::getValue(
"https_request") ===
true);
397 $this->values += $vars;
398 $this->queryString->values += $vars;
408 static $cookiePrefix =
null;
409 if ($cookiePrefix ===
null)
411 $cookiePrefix = Config\Option::get(
"main",
"cookie_name",
"BITRIX_SM") .
"_";
414 $cookiePrefixLength = mb_strlen($cookiePrefix);
417 $cookiesNew = $cookiesToDecrypt = [];
418 foreach (
$cookies as $name => $value)
420 if (mb_strpos($name, $cookiePrefix) !== 0)
425 $name = mb_substr($name, $cookiePrefixLength);
426 if (is_string($value) && $cookiesCrypter->shouldDecrypt($name, $value))
428 $cookiesToDecrypt[$name] = $value;
432 $cookiesNew[$name] = $value;
436 foreach ($cookiesToDecrypt as $name => $value)
438 $cookiesNew[$name] = $cookiesCrypter->decrypt($name, $value, $cookiesNew);
447 foreach (
$server as $name => $value)
449 if (str_starts_with($name,
'HTTP_'))
451 $headerName = substr($name, 5);
454 elseif (in_array($name, [
'CONTENT_TYPE',
'CONTENT_LENGTH'],
true))
460 return $this->normalizeHeaders(
$headers);
463 private function normalizeHeaders(array
$headers)
465 $normalizedHeaders = [];
466 foreach (
$headers as $name => $value)
468 $headerName = strtolower(str_replace(
'_',
'-', $name));
469 $normalizedHeaders[$headerName] = $value;
472 return $normalizedHeaders;
477 if (str_ends_with($path,
"/"))
479 $path .=
"index.php";
482 $path = IO\Path::normalize($path);
495 if ($scriptName ==
"/bitrix/routing_index.php" || $scriptName ==
"/bitrix/urlrewrite.php" || $scriptName ==
"/404.php" || $scriptName ==
"/bitrix/virtual_file_system.php")
497 if (($v = $this->server->get(
"REAL_FILE_PATH")) !=
null)
518 "confirm_registration",
521 "bitrix_include_areas",
523 "show_page_exec_time",
524 "show_include_exec_time",
539 return file_get_contents(
"php://input");
553 $contentType = $this->headers->getContentType();
558 if ($contentType ===
'application/json')
563 return str_contains($contentType,
'+json');
575 $json = Web\Json::decode(static::getInput());
prepareCookie(array $cookies)
modifyByQueryString($queryString)
addFilter(Type\IRequestFilter $filter)
__construct(Server $server, array $queryString, array $postData, array $files, array $cookies)
static getSystemParameters()
setValuesNoDemand(array $values)