1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Request.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\UpdateSystem;
4
5
use Bitrix\Main\SystemException;
6
use Bitrix\Main\Web\HttpClient;
7
use Bitrix\Main\Web\HttpHeaders;
8
use Bitrix\Main\Web\Uri;
9
10
class
Request
11
{
12
private
string
$method =
'POST'
;
13
private
?
array
$body =
null
;
14
private
Uri
$url;
15
private
HttpClient
$httpClient;
16
17
public
function
__construct
()
18
{
19
$this->httpClient =
new
HttpClient
();
20
$this->httpClient->setVersion(
'1.0'
);
21
}
22
23
public
function
setHeaders
(
HttpHeaders
$headers): void
24
{
25
$this->httpClient->setHeaders($headers->toArray());
26
}
27
28
public
function
setUrl
(
Uri
$url): void
29
{
30
$this->url = $url;
31
}
32
33
public
function
setMethod
(
string
$method): void
34
{
35
$this->method = $method;
36
}
37
38
public
function
setProxy
(
array
$proxyData): void
39
{
40
if
(
41
isset($proxyData[
'host'
])
42
&& !empty($proxyData[
'host'
])
43
&& isset($proxyData[
'port'
])
44
&& !empty($proxyData[
'port'
])
45
) {
46
$this->httpClient->setProxy(
47
$proxyData[
'host'
],
48
$proxyData[
'port'
],
49
$proxyData[
'user'
] ??
null
,
50
$proxyData[
'password'
] ??
null
,
51
);
52
}
53
}
54
55
public
function
setBody
(
array
$body): void
56
{
57
$this->body = $body;
58
}
59
64
public
function
send
(): string
65
{
66
$this->url->addParams($this->body);
67
$isSuccess = $this->httpClient->query(
68
$this->method,
69
$this->url->getLocator(),
70
$this->body
71
);
72
73
if
($isSuccess)
74
{
75
return
$this->httpClient->getResult();
76
}
77
else
78
{
79
if
($this->httpClient->getStatus() === 0 && empty($this->httpClient->getError()))
80
{
81
throw
new \Exception(
'Invalid response from host: '
.$this->url->getHost().
' [RS01]'
, 400);
82
}
83
else
84
{
85
throw
new
SystemException
(implode(
'\r\n'
, $this->httpClient->getError()).
' [RS02]'
);
86
}
87
}
88
}
89
}
Bitrix\Main\SystemException
Определения
SystemException.php:9
Bitrix\Main\UpdateSystem\Request
Определения
Request.php:11
Bitrix\Main\UpdateSystem\Request\__construct
__construct()
Определения
Request.php:17
Bitrix\Main\UpdateSystem\Request\send
send()
Определения
Request.php:64
Bitrix\Main\UpdateSystem\Request\setProxy
setProxy(array $proxyData)
Определения
Request.php:38
Bitrix\Main\UpdateSystem\Request\setMethod
setMethod(string $method)
Определения
Request.php:33
Bitrix\Main\UpdateSystem\Request\setUrl
setUrl(Uri $url)
Определения
Request.php:28
Bitrix\Main\UpdateSystem\Request\setBody
setBody(array $body)
Определения
Request.php:55
Bitrix\Main\UpdateSystem\Request\setHeaders
setHeaders(HttpHeaders $headers)
Определения
Request.php:23
Bitrix\Main\Web\HttpClient
Определения
httpclient.php:24
Bitrix\Main\Web\HttpHeaders
Определения
httpheaders.php:18
Bitrix\Main\Web\Uri
Определения
uri.php:17
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
bitrix
modules
main
lib
UpdateSystem
Request.php
Создано системой
1.14.0