19 declare(strict_types=1);
38 protected string $url =
'',
41 if (!self::_isCurlExtensionLoaded()) {
48 if (!function_exists(
'curl_init')) {
64 final public function init(
bool $set_proxy =
true): bool
68 if ($this->url !==
'') {
69 $this->ch = curl_init($this->url);
71 $this->ch = curl_init();
76 if (curl_errno($this->ch)) {
83 if ($proxy->isActive()) {
84 $this->
setOpt(CURLOPT_HTTPPROXYTUNNEL,
true);
86 if (!empty($proxy->getHost())) {
87 $this->
setOpt(CURLOPT_PROXY, $proxy->getHost());
91 if (!empty($proxy->getPort())) {
92 $this->
setOpt(CURLOPT_PROXYPORT, $proxy->getPort());
105 final public function setOpt(
int $a_option, $a_value): bool
107 if (!curl_setopt($this->ch, $a_option, $a_value)) {
120 curl_setopt($this->ch, CURLOPT_HEADERFUNCTION, array($this,
'parseHeader'));
121 if ((
$res = curl_exec($this->ch)) ===
false) {
122 if (($err = curl_error($this->ch)) !==
'') {
133 $header_size = $this->
getInfo(CURLINFO_HEADER_SIZE);
135 $this->header_plain = substr($a_response, 0, $header_size);
136 $this->response_body = substr($a_response, $header_size);
154 $res = curl_getinfo($this->ch, $opt);
156 $res = curl_getinfo($this->ch);
169 $len = strlen($header);
170 $header = explode(
':', $header, 2);
171 if (count($header) === 2) {
172 $this->header_arr[strtolower(trim($header[0]))] = trim($header[1]);
179 if ($this->ch !==
null) {
180 curl_close($this->ch);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(protected string $url='', protected ?ilProxySettings $proxySettings=null,)
exec()
Wrapper for curl_exec.
init(bool $set_proxy=true)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
parseResponse(string $a_response)
static _isCurlExtensionLoaded()
setOpt(int $a_option, $a_value)
Wrapper for curl_setopt.
getInfo($opt=0)
Get information about a specific transfer.
parseHeader($handle, string $header)
Parse respone header.