2 namespace TYPO3\CMS\Core\Http;
104 if (!is_string($uri)) {
105 $argumentType = is_object($uri) ? get_class($uri) : gettype($uri);
106 throw new \InvalidArgumentException(
'URI passed must be a string, but is of type "' . $argumentType .
'"', 1436717320);
120 $uriParts = parse_url($uri);
122 if ($uriParts ===
false) {
123 throw new \InvalidArgumentException(
'The parsedUri string appears to be malformed', 1436717322);
126 if (isset($uriParts[
'scheme'])) {
130 if (isset($uriParts[
'user'])) {
131 $this->userInfo = $uriParts[
'user'];
132 if (isset($uriParts[
'pass'])) {
133 $this->userInfo .=
':' . $uriParts[
'pass'];
137 if (isset($uriParts[
'host'])) {
138 $this->host = $uriParts[
'host'];
141 if (isset($uriParts[
'port'])) {
142 $this->
port = (int)$uriParts[
'port'];
145 if (isset($uriParts[
'path'])) {
149 if (isset($uriParts[
'query'])) {
153 if (isset($uriParts[
'fragment'])) {
197 if (empty($this->host)) {
202 if (!empty($this->userInfo)) {
365 $clonedObject = clone $this;
366 $clonedObject->scheme =
$scheme;
367 return $clonedObject;
388 if (!empty($password)) {
392 $clonedObject = clone $this;
394 return $clonedObject;
412 $clonedObject = clone $this;
413 $clonedObject->host =
$host;
414 return $clonedObject;
437 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger(
$port) ===
false) {
439 throw new \InvalidArgumentException(
'Invalid port "' . $argumentType .
'" specified, must be an integer.', 1436717324);
443 if ($port < 1 || $port > 65535) {
444 throw new \InvalidArgumentException(
'Invalid port "' .
$port .
'" specified, must be a valid TCP/UDP port.', 1436717326);
447 $clonedObject = clone $this;
448 $clonedObject->port =
$port;
449 return $clonedObject;
477 if (!is_string(
$path)) {
478 throw new \InvalidArgumentException(
'Invalid path provided. Must be of type string.', 1436717328);
481 if (strpos(
$path,
'?') !==
false) {
482 throw new \InvalidArgumentException(
'Invalid path provided. Must not contain a query string.', 1436717330);
485 if (strpos(
$path,
'#') !==
false) {
486 throw new \InvalidArgumentException(
'Invalid path provided; must not contain a URI fragment', 1436717332);
490 $clonedObject = clone $this;
491 $clonedObject->path =
$path;
492 return $clonedObject;
514 throw new \InvalidArgumentException(
'Query string must be a string.', 1436717334);
517 if (strpos(
$query,
'#') !==
false) {
518 throw new \InvalidArgumentException(
'Query string must not include a URI fragment.', 1436717336);
522 $clonedObject = clone $this;
523 $clonedObject->query =
$query;
524 return $clonedObject;
545 $clonedObject = clone $this;
547 return $clonedObject;
577 if (!empty($this->scheme)) {
578 $uri .= $this->scheme .
'://';
588 $uri .=
'/' . ltrim(
$path,
'/');
594 if ($this->fragment) {
618 return !isset($this->supportedSchemes[
$scheme]) ||
$port !== $this->supportedSchemes[
$scheme];
638 if (!array_key_exists(
$scheme, $this->supportedSchemes)) {
639 throw new \InvalidArgumentException(
'Unsupported scheme "' .
$scheme .
'"; must be any empty string or in the set (' . implode(
', ', array_keys($this->supportedSchemes)) .
')', 1436717338);
653 return preg_replace_callback(
654 '/(?:[^' . self::UNRESERVED_CHARLIST .
':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
655 function ($matches) {
656 return rawurlencode($matches[0]);
676 $parts = explode(
'&',
$query);
677 foreach ($parts as $index => $part) {
679 if ($value === null) {
686 return implode(
'&', $parts);
697 $data = explode(
'=', $value, 2);
698 if (count($data) === 1) {
731 return preg_replace_callback(
732 '/(?:[^' . self::UNRESERVED_CHARLIST . self::SUBDELIMITER_CHARLIST .
'%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
733 function ($matches) {
734 return rawurlencode($matches[0]);