|
@@ -78,6 +78,19 @@ class Curl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ public function setStream($callback)
|
|
|
+ {
|
|
|
+ curl_setopt($this->handle, CURLOPT_BUFFERSIZE, 16384);
|
|
|
+
|
|
|
+ curl_setopt($this->handle,CURLOPT_TCP_KEEPALIVE,1);
|
|
|
+ curl_setopt($this->handle,CURLOPT_TCP_KEEPIDLE,10);
|
|
|
+ curl_setopt($this->handle,CURLOPT_TCP_KEEPINTVL,10);
|
|
|
+ curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, function ($ch, $data) use ($callback) {
|
|
|
+ call_user_func($callback, $data);
|
|
|
+ return strlen($data);
|
|
|
+ });
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
public function setRequest($type)
|
|
|
{
|
|
|
if ($type == 'post' || $type == 'file') {
|
|
@@ -197,6 +210,9 @@ class Curl
|
|
|
Dever::log($debug, 'curl');
|
|
|
}
|
|
|
Dever::debug($debug, 'curl');
|
|
|
+ if (isset($setting['stream'])) {
|
|
|
+ exit;
|
|
|
+ }
|
|
|
return $result;
|
|
|
} catch (\Exception $e) {
|
|
|
curl_close($this->handle);
|