diff options
-rw-r--r-- | it_url.class | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class index 0e81354..aa2ce4a 100644 --- a/it_url.class +++ b/it_url.class @@ -1,6 +1,6 @@ <?php /* -** Copyright (C) 1995-2021 by the ITools Authors. +** Copyright (C) 1995-2022 by the ITools Authors. ** This file is part of ITools - the Internet Tools Library ** ** ITools is free software; you can redistribute it and/or modify @@ -268,6 +268,7 @@ static function curl_opts($p=array()) function request($p=array()) { + static $curl; $url = $this; if ($p['url']) $this->__construct($p['url']); @@ -281,7 +282,14 @@ function request($p=array()) $stderr = it::fopen("php://memory", "r+"); $opts += [CURLOPT_STDERR => $stderr, CURLOPT_VERBOSE => 1]; } - $curl = curl_init($url->url); + if (!isset($curl)) + $curl = curl_init($url->url); + else + { + curl_reset($curl); + curl_setopt($curl, CURLOPT_URL, $url->url); + } + if ($p['maxlength'] && !$p['writefunction']) { @@ -372,6 +380,7 @@ function request($p=array()) */ static function get_multi($p=null) { + static $mh; $p += array('retries' => 1); EDC('req', $p); @@ -381,7 +390,8 @@ static function get_multi($p=null) $opts = self::curl_opts($p); - $mh = curl_multi_init(); + if (!isset($mh)) + $mh = curl_multi_init(); $keys = $handles = $urls = $retries = []; $addhandle = function ($key, $url) use (&$keys, &$handles, &$urls, $opts, $mh) { |