1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
queue.php
См. документацию.
1
<?php
2
9
10
namespace
Bitrix\Main\Web\Http\Curl;
11
12
use Bitrix\Main\Web\Http;
13
use Bitrix\Main\Web\HttpDebug;
14
15
class
Queue
extends
Http\Queue
16
{
18
protected
array
$promises
= [];
19
protected \CurlMultiHandle
$handle
;
20
21
public
function
__construct
()
22
{
23
parent::__construct();
24
25
$this->handle = curl_multi_init();
26
}
27
28
public
function
__destruct
()
29
{
30
curl_multi_close($this->handle);
31
}
32
39
public
function
add
(
Promise
$promise): void
40
{
41
$this->promises[$promise->
getId
()] = $promise;
42
43
curl_multi_add_handle($this->handle, $promise->
getHandler
()->getHandle());
44
}
45
46
protected
function
delete
(
string
$promiseId): void
47
{
48
curl_multi_remove_handle($this->handle, $this->promises[$promiseId]->getHandler()->getHandle());
49
50
unset($this->promises[$promiseId]);
51
}
52
56
public
function
wait
(?
Http
\
Promise
$targetPromise =
null
):
array
57
{
58
$processedPromises = [];
59
60
if
(empty($this->promises))
61
{
62
return
$processedPromises;
63
}
64
65
do
66
{
67
$fetchBody =
true
;
68
69
try
70
{
71
$status
= curl_multi_exec($this->handle, $active);
72
}
73
catch
(
SkipBodyException
)
74
{
75
$fetchBody =
false
;
76
}
77
78
$info
= curl_multi_info_read($this->handle);
79
80
if
(
$info
!==
false
)
81
{
82
$promiseId = spl_object_hash(
$info
[
'handle'
]);
83
84
$promise = $this->promises[$promiseId];
85
$handler = $promise->getHandler();
86
87
if
(!$fetchBody)
88
{
89
// we don't want a body, just fulfil a promise with response headers
90
$promise->fulfill($handler->getResponse());
91
}
92
elseif
(
$info
[
'result'
] === CURLE_OK)
93
{
94
$response
= $handler->getResponse();
95
96
if
($handler->getDebugLevel() &
HttpDebug::RESPONSE_BODY
)
97
{
98
$handler->log(
$response
->getBody(),
HttpDebug::RESPONSE_BODY
);
99
}
100
101
// need to ajust the response headers (PSR-18)
102
$response
->adjustHeaders();
103
104
$promise->fulfill(
$response
);
105
106
$handler->logDiagnostics();
107
}
108
else
109
{
110
$error
= curl_error(
$info
[
'handle'
]);
111
112
$promise->reject(
new
Http
\
NetworkException
($promise->getRequest(),
$error
));
113
114
$handler->getLogger()?->error(
$error
.
"\n"
);
115
}
116
117
// job done, the promise is fullfilled or rejected
118
$processedPromises[] = $promise;
119
120
$this->
delete
($promiseId);
121
122
if
($targetPromise && $promiseId === $targetPromise->getId())
123
{
124
// we were waiting for the specific promise
125
return
$processedPromises;
126
}
127
}
128
}
129
while
(
$status
=== CURLM_CALL_MULTI_PERFORM || $active);
130
131
return
$processedPromises;
132
}
133
}
Bitrix\Main\Web\Http\Curl\Promise
Определения
promise.php:15
Bitrix\Main\Web\Http\Curl\Promise\getHandler
getHandler()
Определения
promise.php:30
Bitrix\Main\Web\Http\Curl\Queue
Определения
queue.php:16
Bitrix\Main\Web\Http\Curl\Queue\add
add(Promise $promise)
Определения
queue.php:39
Bitrix\Main\Web\Http\Curl\Queue\__construct
__construct()
Определения
queue.php:21
Bitrix\Main\Web\Http\Curl\Queue\__destruct
__destruct()
Определения
queue.php:28
Bitrix\Main\Web\Http\Curl\Queue\wait
wait(?Http\Promise $targetPromise=null)
Определения
queue.php:56
Bitrix\Main\Web\Http\Curl\Queue\$promises
array $promises
Определения
queue.php:18
Bitrix\Main\Web\Http\Curl\Queue\$handle
CurlMultiHandle $handle
Определения
queue.php:19
Bitrix\Main\Web\Http\Curl\SkipBodyException
Определения
skipbodyexception.php:13
Bitrix\Main\Web\Http\NetworkException
Определения
networkexception.php:8
Bitrix\Main\Web\Http\Promise\getId
getId()
Определения
promise.php:166
Bitrix\Main\Web\Http\Queue
Определения
queue.php:15
Bitrix\Main\Web\HttpDebug\RESPONSE_BODY
const RESPONSE_BODY
Определения
httpdebug.php:18
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$status
$status
Определения
session.php:10
$info
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения
backup.php:924
Bitrix\Main\Web\Http
Определения
clientexception.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$response
$response
Определения
result.php:21
$error
$error
Определения
subscription_card_product.php:20
bitrix
modules
main
lib
web
http
curl
queue.php
Создано системой
1.14.0