Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
handler.php
1
<?php
2
10
namespace
Bitrix\Main\Web\Http
;
11
12
use Psr\Log;
13
use
Bitrix\Main\Diag
;
14
use Psr\Http\Message\RequestInterface;
15
16
class
Handler
implements
Log\LoggerAwareInterface,
DebugInterface
17
{
18
use Log\LoggerAwareTrait;
19
use
DebugInterfaceTrait
;
20
21
protected
bool
$waitResponse
=
true
;
22
protected
int
$bodyLengthMax
= 0;
23
24
protected
RequestInterface
$request
;
25
protected
ResponseBuilder
$responseBuilder
;
26
protected
$shouldFetchBody
=
null
;
27
protected
string
$responseHeaders
=
''
;
28
protected
?
Response
$response
=
null
;
29
private
bool
$logStarted =
false
;
30
36
public
function
__construct
(RequestInterface
$request
,
ResponseBuilder
$responseBuilder
, array $options = [])
37
{
38
$this->request =
$request
;
39
$this->responseBuilder =
$responseBuilder
;
40
41
if
(isset($options[
'waitResponse'
]))
42
{
43
$this->waitResponse = (bool)$options[
'waitResponse'
];
44
}
45
if
(isset($options[
'bodyLengthMax'
]))
46
{
47
$this->bodyLengthMax = (int)$options[
'bodyLengthMax'
];
48
}
49
}
50
54
public
function
getRequest
(): RequestInterface
55
{
56
return
$this->request
;
57
}
58
62
public
function
getResponse
(): ?
Response
63
{
64
return
$this->response
;
65
}
66
72
public
function
getLogger
()
73
{
74
if
($this->logger ===
null
)
75
{
76
$logger = Diag\Logger::create(
'main.HttpClient'
, [$this, $this->request]);
77
78
if
($logger !==
null
)
79
{
80
$this->setLogger($logger);
81
}
82
}
83
84
return
$this->logger;
85
}
86
87
public
function
log
(
string
$logMessage,
int
$level): void
88
{
89
if
(($logger = $this->
getLogger
()) && ($this->debugLevel & $level))
90
{
91
$message =
''
;
92
$context = [];
93
if
(!$this->logStarted)
94
{
95
$this->logStarted =
true
;
96
$message =
"\n{delimiter}\n{date} - {host}\n{trace}"
;
97
$context = [
'trace'
=> Diag\Helper::getBackTrace(10, DEBUG_BACKTRACE_IGNORE_ARGS, 5)];
98
}
99
100
$message .= $logMessage;
101
102
$logger->debug($message, $context);
103
}
104
}
105
112
public
function
shouldFetchBody
(callable $callback): void
113
{
114
$this->
shouldFetchBody
= $callback;
115
}
116
}
Bitrix\Main\Response
Definition
response.php:5
Bitrix\Main\Web\Http\Handler
Definition
handler.php:17
Bitrix\Main\Web\Http\Handler\shouldFetchBody
shouldFetchBody(callable $callback)
Definition
handler.php:112
Bitrix\Main\Web\Http\Handler\getLogger
getLogger()
Definition
handler.php:72
Bitrix\Main\Web\Http\Handler\$request
RequestInterface $request
Definition
handler.php:24
Bitrix\Main\Web\Http\Handler\__construct
__construct(RequestInterface $request, ResponseBuilder $responseBuilder, array $options=[])
Definition
handler.php:36
Bitrix\Main\Web\Http\Handler\$shouldFetchBody
$shouldFetchBody
Definition
handler.php:26
Bitrix\Main\Web\Http\Handler\$responseHeaders
string $responseHeaders
Definition
handler.php:27
Bitrix\Main\Web\Http\Handler\$response
Response $response
Definition
handler.php:28
Bitrix\Main\Web\Http\Handler\getResponse
getResponse()
Definition
handler.php:62
Bitrix\Main\Web\Http\Handler\$waitResponse
bool $waitResponse
Definition
handler.php:21
Bitrix\Main\Web\Http\Handler\$bodyLengthMax
int $bodyLengthMax
Definition
handler.php:22
Bitrix\Main\Web\Http\Handler\$responseBuilder
ResponseBuilder $responseBuilder
Definition
handler.php:25
Bitrix\Main\Web\Http\Handler\log
log(string $logMessage, int $level)
Definition
handler.php:87
Bitrix\Main\Web\Http\Handler\getRequest
getRequest()
Definition
handler.php:54
Bitrix\Main\Web\Http\ResponseBuilder
Definition
responsebuilder.php:15
Bitrix\Main\Web\Http\DebugInterface
Definition
debuginterface.php:13
Bitrix\Main\Diag
Definition
cachetracker.php:2
Bitrix\Main\Web\Http
Definition
clientexception.php:3
Bitrix\Main\Web\Http\DebugInterfaceTrait
trait DebugInterfaceTrait
Definition
debuginterfacetrait.php:15
modules
main
lib
web
http
handler.php
Создано системой
1.10.0