Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
response.php
1
<?php
2
10
namespace
Bitrix\Main\Web\Http
;
11
12
use Psr\Http\Message\ResponseInterface;
13
use Psr\Http\Message\StreamInterface;
14
15
class
Response
extends
Message
implements ResponseInterface
16
{
17
public
function
__construct
(
int
$statusCode, array $headers =
null
, StreamInterface $body =
null
,
string
$version =
null
,
string
$reasonPhrase =
''
)
18
{
19
parent::__construct(
$headers
,
$body
, $version);
20
21
$this->headers->setStatus($statusCode, $reasonPhrase);
22
}
23
27
public
function
getStatusCode
(): int
28
{
29
return
$this->headers->getStatus();
30
}
31
35
public
function
withStatus
(
int
$code,
string
$reasonPhrase =
''
): ResponseInterface
36
{
37
$new = clone $this;
38
$new->headers->setStatus($code, $reasonPhrase);
39
40
return
$new;
41
}
42
46
public
function
getReasonPhrase
(): string
47
{
48
return
$this->headers->getReasonPhrase();
49
}
50
55
public
function
adjustHeaders
(): void
56
{
57
// If a Client chooses to decompress the message body then it MUST also remove the Content-Encoding header and adjust the Content-Length header
58
if
(strtolower($this->headers->get(
'Content-Encoding'
) ??
''
) ==
'gzip'
)
59
{
60
$this->headers->delete(
'Content-Encoding'
);
61
62
if
($this->headers->has(
'Content-Length'
))
63
{
64
$size = $this->body->getSize();
65
if
($size !==
null
)
66
{
67
$this->headers->set(
'Content-Length'
, $size);
68
}
69
else
70
{
71
$this->headers->delete(
'Content-Length'
);
72
}
73
}
74
}
75
76
// Already dechunked
77
if
(strtolower($this->headers->get(
'Transfer-Encoding'
) ??
''
) ==
'chunked'
)
78
{
79
$this->headers->delete(
'Transfer-Encoding'
);
80
}
81
}
82
}
Bitrix\Main\Response
Definition
response.php:5
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\Response\__construct
__construct(int $statusCode, array $headers=null, StreamInterface $body=null, string $version=null, string $reasonPhrase='')
Definition
response.php:17
Bitrix\Main\Web\Http\Response\getStatusCode
getStatusCode()
Definition
response.php:27
Bitrix\Main\Web\Http\Response\withStatus
withStatus(int $code, string $reasonPhrase='')
Definition
response.php:35
Bitrix\Main\Web\Http\Response\getReasonPhrase
getReasonPhrase()
Definition
response.php:46
Bitrix\Main\Web\Http\Response\adjustHeaders
adjustHeaders()
Definition
response.php:55
Bitrix\Main\Web\Http
Definition
clientexception.php:3
modules
main
lib
web
http
response.php
Создано системой
1.10.0