diff --git a/framework/library/App.php b/framework/library/App.php index 3ba072c..053f617 100644 --- a/framework/library/App.php +++ b/framework/library/App.php @@ -65,7 +65,7 @@ class App private static function initRoute() { $driver = null; - if (php_sapi_name() == 'cli') { + if (Request::instance()->isCLI()) { // 命令行运行程序 $driver = new Command(); } else { diff --git a/framework/library/functions/functions.php b/framework/library/functions/functions.php index 810c0d3..29e1f81 100644 --- a/framework/library/functions/functions.php +++ b/framework/library/functions/functions.php @@ -160,10 +160,14 @@ function create_http_request($url, $data = [], $header = []) curl_setopt($curl, CURLOPT_HEADER, $header); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - $res = curl_exec($curl); + $response = curl_exec($curl); + if (!empty($header)) { + $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); + $response = substr($response, $headerSize); + } curl_close($curl); - if ($res) { - return $res; + if ($response) { + return $response; } return false; } diff --git a/framework/library/http/Request.php b/framework/library/http/Request.php index 0c97f08..25c4e62 100644 --- a/framework/library/http/Request.php +++ b/framework/library/http/Request.php @@ -124,6 +124,15 @@ class Request return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); } + /** + * CLI + * @return boolean + */ + public function isCLI() + { + return (php_sapi_name() == 'cli'); + } + /** * 创建一个请求(post或get取决于data是否有值且不为空或空数组) * @param string $url