From 8f43fd99e67e799369d071fb52166baa3454dac0 Mon Sep 17 00:00:00 2001 From: Shammi Shailaj Date: Sun, 19 May 2019 23:32:53 +0530 Subject: [PATCH] Adding verbosity for cURL (#697) Added code to increase cURL verbosity in cases where PSM_DEBUG is defined and set to a value of boolean TRUE only if the request is coming via CLI. --- src/includes/functions.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 770d0111..4ea81309 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -357,6 +357,9 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = null, $ad $timeout = $timeout == null ? PSM_CURL_TIMEOUT : intval($timeout); $ch = curl_init(); + if(defined('PSM_DEBUG') && PSM_DEBUG === true && psm_is_cli()) { + curl_setopt($ch, CURLOPT_VERBOSE, true); + } curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_NOBODY, (!$body)); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); @@ -397,6 +400,12 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = null, $ad $result = curl_exec($ch); curl_close($ch); + + if(defined('PSM_DEBUG') && PSM_DEBUG === true && psm_is_cli()) { + echo PHP_EOL.'==============cURL Result for: '.$href.'==========================================='.PHP_EOL; + print_r($result); + echo PHP_EOL.'==============END cURL Resul for: '.$href.'==========================================='.PHP_EOL; + } return $result; }