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.
This commit is contained in:
Shammi Shailaj 2019-05-19 23:32:53 +05:30 committed by Tim
parent 6761776a8f
commit 8f43fd99e6
1 changed files with 9 additions and 0 deletions

View File

@ -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;
}