117 $this->_timeout = (int)
$value;
125 $this->sslVersion = $sslVersion;
136 $this->_headers = $headers;
159 unset($this->_headers[
$name]);
172 $val = base64_encode(
"{$login}:{$pass}");
173 $this->
addHeader(
"Authorization",
"Basic {$val}");
196 unset($this->_cookies[
$name]);
207 $this->_cookies = $cookies;
225 public function get($uri)
274 if (empty($this->_responseHeaders[
'Set-Cookie'])) {
278 foreach ($this->_responseHeaders[
'Set-Cookie'] as
$row) {
284 list($key, $val) = explode(
"=",
$values[0]);
288 $out[trim($key)] = trim($val);
300 if (empty($this->_responseHeaders[
'Set-Cookie'])) {
304 foreach ($this->_responseHeaders[
'Set-Cookie'] as
$row) {
310 list($key, $val) = explode(
"=",
$values[0]);
314 $out[trim($key)] = [
'value' => trim($val)];
320 for (
$i = 0;
$i < $c;
$i++) {
321 list($subkey, $val) = explode(
"=",
$values[
$i]);
322 $out[trim($key)][trim($subkey)] = trim($val);
354 $this->_ch = curl_init();
365 if (count($this->_headers)) {
367 foreach ($this->_headers as $k => $v) {
368 $heads[] = $k .
': ' . $v;
370 $this->
curlOption(CURLOPT_HTTPHEADER, $heads);
373 if (count($this->_cookies)) {
375 foreach ($this->_cookies as $k => $v) {
376 $cookies[] =
"{$k}={$v}";
378 $this->
curlOption(CURLOPT_COOKIE, implode(
";", $cookies));
381 if ($this->_timeout) {
382 $this->
curlOption(CURLOPT_TIMEOUT, $this->_timeout);
385 if ($this->_port != 80) {
386 $this->
curlOption(CURLOPT_PORT, $this->_port);
390 $this->
curlOption(CURLOPT_HEADERFUNCTION, [$this,
'parseHeaders']);
391 if ($this->sslVersion !==
null) {
392 $this->
curlOption(CURLOPT_SSLVERSION, $this->sslVersion);
395 if (count($this->_curlUserOptions)) {
396 foreach ($this->_curlUserOptions as $k => $v) {
401 $this->_headerCount = 0;
402 $this->_responseHeaders = [];
403 $this->_responseBody =
curl_exec($this->_ch);
404 $err = curl_errno($this->_ch);
406 $this->
doError(curl_error($this->_ch));
408 curl_close($this->_ch);
419 throw new \Exception($string);
433 if ($this->_headerCount == 0) {
434 $line = explode(
" ", trim(
$data), 3);
435 if (count($line) != 3) {
436 $this->
doError(
"Invalid response line returned from server: " .
$data);
438 $this->_responseStatus = intval($line[1]);
441 $out = explode(
": ", trim(
$data), 2);
442 if (count($out) == 2) {
448 if (
"Set-Cookie" ==
$name) {
449 if (!isset($this->_responseHeaders[
$name])) {
450 $this->_responseHeaders[
$name] = [];
458 $this->_headerCount++;
460 return strlen(
$data);
482 curl_setopt_array($this->_ch, $arr);
492 $this->_curlUserOptions = $arr;
elseif(isset( $params[ 'redirect_parent']))
__construct($sslVersion=null)
curlOption($name, $value)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
makeRequest($method, $uri, $params=[])
setCredentials($login, $pass)
if(!isset($_GET['name'])) $name