Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
request.php
1
<?php
2
10
namespace
Bitrix\Main\Web\Http
;
11
12
use Psr\Http\Message\UriInterface;
13
use Psr\Http\Message\RequestInterface;
14
use Psr\Http\Message\StreamInterface;
15
16
class
Request
extends
Message
implements RequestInterface
17
{
18
protected
$requestTarget
;
19
protected
UriInterface
$uri
;
20
protected
$method
;
21
22
public
function
__construct
(
string
$method, UriInterface $uri, array $headers =
null
, StreamInterface $body =
null
,
string
$version =
null
)
23
{
24
parent::__construct(
$headers
,
$body
, $version);
25
26
$this->method = $method;
27
$this->uri = $uri;
28
29
// PSR-7: During construction, implementations MUST attempt to set the Host header from a provided URI if no Host header is provided.
30
if
($uri->getHost() !=
''
&& !$this->hasHeader(
'Host'
))
31
{
32
$this->headers->set(
'Host'
, $uri->getHost());
33
}
34
}
35
39
public
function
getRequestTarget
(): string
40
{
41
if
($this->requestTarget !==
null
)
42
{
43
return
$this->requestTarget;
44
}
45
46
$target = $this->uri->getPath();
47
48
if
($target ==
''
)
49
{
50
$target =
'/'
;
51
}
52
53
$query = $this->uri->getQuery();
54
55
if
($query !=
''
)
56
{
57
$target .=
'?'
. $query;
58
}
59
60
return
$target;
61
}
62
66
public
function
withRequestTarget
(
string
$requestTarget): RequestInterface
67
{
68
$new = clone $this;
69
$new->requestTarget = $requestTarget;
70
71
return
$new;
72
}
73
77
public
function
getMethod
(): string
78
{
79
return
$this->method;
80
}
81
85
public
function
withMethod
(
string
$method): RequestInterface
86
{
87
$new = clone $this;
88
$new->method = $method;
89
90
return
$new;
91
}
92
96
public
function
getUri
(): UriInterface
97
{
98
return
$this->uri;
99
}
100
104
public
function
withUri
(UriInterface $uri,
bool
$preserveHost =
false
): RequestInterface
105
{
106
$new = clone $this;
107
$new->uri = $uri;
108
109
$newHost = $uri->getHost();
110
111
if
($newHost !=
''
)
112
{
113
if
(!$preserveHost || !$new->hasHeader(
'Host'
))
114
{
115
$new->headers->set(
'Host'
, $newHost);
116
}
117
}
118
119
return
$new;
120
}
121
122
public
function
__clone
()
123
{
124
$this->uri = clone $this->uri;
125
parent::__clone();
126
}
127
}
Bitrix\Main\Request
Definition
request.php:10
Bitrix\Main\Web\Http\Message
Definition
message.php:17
Bitrix\Main\Web\Http\Message\$headers
HttpHeaders $headers
Definition
message.php:18
Bitrix\Main\Web\Http\Message\$body
StreamInterface $body
Definition
message.php:19
Bitrix\Main\Web\Http\Request\getRequestTarget
getRequestTarget()
Definition
request.php:39
Bitrix\Main\Web\Http\Request\$method
$method
Definition
request.php:20
Bitrix\Main\Web\Http\Request\withUri
withUri(UriInterface $uri, bool $preserveHost=false)
Definition
request.php:104
Bitrix\Main\Web\Http\Request\__construct
__construct(string $method, UriInterface $uri, array $headers=null, StreamInterface $body=null, string $version=null)
Definition
request.php:22
Bitrix\Main\Web\Http\Request\getUri
getUri()
Definition
request.php:96
Bitrix\Main\Web\Http\Request\$requestTarget
$requestTarget
Definition
request.php:18
Bitrix\Main\Web\Http\Request\$uri
UriInterface $uri
Definition
request.php:19
Bitrix\Main\Web\Http\Request\__clone
__clone()
Definition
request.php:122
Bitrix\Main\Web\Http\Request\withRequestTarget
withRequestTarget(string $requestTarget)
Definition
request.php:66
Bitrix\Main\Web\Http\Request\getMethod
getMethod()
Definition
request.php:77
Bitrix\Main\Web\Http\Request\withMethod
withMethod(string $method)
Definition
request.php:85
Bitrix\Main\Web\Http
Definition
clientexception.php:3
modules
main
lib
web
http
request.php
Создано системой
1.10.0