X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fcurl-de-sac.phh;h=38fcc8ce8a17433bb823cbd379540b43a19e9785;hb=e738329c263f493110d9c7bacd29c983ba9f583b;hp=01ba78b81dee6322e46c438d91c82712abc7a65c;hpb=aa32018692a341fb130b5632ab2a1a58041de239;p=curl-de-sac.git diff --git a/web/Obj/curl-de-sac.phh b/web/Obj/curl-de-sac.phh index 01ba78b..38fcc8c 100644 --- a/web/Obj/curl-de-sac.phh +++ b/web/Obj/curl-de-sac.phh @@ -22,7 +22,8 @@ * */ -$G_curl_de_sac_version = "0.1"; +define('CURL_DE_SAC_VERS', '0.1'); +$G_curl_de_sac_vers = CURL_DE_SAC_VERS; class CDS_cmd { var $cmd_cls; @@ -67,16 +68,23 @@ class CDS_cmd_cls { $this->cds = $cds; } - static function pre_create($cds, $url) + static function pre_create($cds, $url, $opts=NULL) { if ($cds->dbg_get() > 2) { printf("CURL: curl_init\n"); } if (($ch = curl_init()) == FALSE) return FALSE; curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_FORBID_REUSE, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); + if ($opts == NULL) { + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FORBID_REUSE, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); + } + else { + foreach($opts as $opt => $value) { + curl_setopt($ch, $opt, $value); + } + } return ($ch); } @@ -211,9 +219,11 @@ class Curl_de_sac { $cmd_cls = $this->cmd_cls[$name]; - if (($inst = call_user_func_array(array($cmd_cls, "create"), $args)) == FALSE) + // custom create now can return synchronously returning true instead of a + // "command instance class" instance or false if any error occurs + $inst = call_user_func_array(array($cmd_cls, "create"), $args); + if (is_bool($inst)) break; - array_push($this->cmd, $inst); if ($this->dbg > 1) { printf("CDS_cmd_cls::process - execute push cmd\n"); } if (($this->dbg & 1) == 1) { print_r($this); } @@ -221,7 +231,7 @@ class Curl_de_sac { return TRUE; } while (FALSE); - return FALSE; + return $inst; } function process($curtime=0)