22 'protocols' => (CURLPROTO_HTTP
44 'timeout' => CURLOPT_TIMEOUT,
45 'maxredirects' => CURLOPT_MAXREDIRS,
46 'proxy' => CURLOPT_PROXY,
47 'ssl_cert' => CURLOPT_SSLCERT,
48 'userpwd' => CURLOPT_USERPWD,
49 'useragent' => CURLOPT_USERAGENT,
50 'referer' => CURLOPT_REFERER,
51 'protocols' => CURLOPT_PROTOCOLS,
52 'verifypeer' => CURLOPT_SSL_VERIFYPEER,
53 'verifyhost' => CURLOPT_SSL_VERIFYHOST,
54 'sslversion' => CURLOPT_SSLVERSION,
89 private function getDefaultConfig()
92 foreach (array_keys($this->_config) as $param) {
93 if (array_key_exists($param, $this->_allowedParams)) {
94 $config[$this->_allowedParams[$param]] = $this->_config[$param];
134 $this->_config[$key] =
$value;
148 public function connect($host, $port = 80, $secure =
false)
170 curl_setopt($this->
_getResource(), CURLOPT_RETURNTRANSFER,
true);
173 curl_setopt($this->
_getResource(), CURLOPT_CUSTOMREQUEST,
'POST');
174 curl_setopt($this->
_getResource(), CURLOPT_POSTFIELDS, $body);
176 curl_setopt($this->
_getResource(), CURLOPT_CUSTOMREQUEST,
'PUT');
177 curl_setopt($this->
_getResource(), CURLOPT_POSTFIELDS, $body);
179 curl_setopt($this->
_getResource(), CURLOPT_HTTPGET,
true);
180 curl_setopt($this->
_getResource(), CURLOPT_CUSTOMREQUEST,
'GET');
183 if (is_array($headers)) {
184 curl_setopt($this->
_getResource(), CURLOPT_HTTPHEADER, $headers);
190 $header = isset($this->_config[
'header']) ? $this->_config[
'header'] :
true;
191 curl_setopt($this->
_getResource(), CURLOPT_HEADER, $header);
227 $this->_resource =
null;
238 if ($this->_resource ===
null) {
239 $this->_resource = curl_init();
287 $multihandle = curl_multi_init();
290 foreach ($this->getDefaultConfig() as $defaultOption => $defaultValue) {
291 if (!isset(
$options[$defaultOption])) {
292 $options[$defaultOption] = $defaultValue;
297 $handles[$key] = curl_init();
298 curl_setopt($handles[$key], CURLOPT_URL,
$url);
299 curl_setopt($handles[$key], CURLOPT_HEADER, 0);
300 curl_setopt($handles[$key], CURLOPT_RETURNTRANSFER, 1);
302 curl_setopt_array($handles[$key],
$options);
304 curl_multi_add_handle($multihandle, $handles[$key]);
308 curl_multi_exec($multihandle, $process);
310 }
while ($process > 0);
312 foreach ($handles as $key =>
$handle) {
314 curl_multi_remove_handle($multihandle,
$handle);
316 curl_multi_close($multihandle);
elseif(isset( $params[ 'redirect_parent']))
setOptions(array $options=[])
addOption($option, $value)
multiRequest($urls, $options=[])
write($method, $url, $http_ver='1.1', $headers=[], $body='')
connect($host, $port=80, $secure=false)
static extractCode($response_str)