summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_url.class16
1 files changed, 14 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class
index 15f2f2f..8542fff 100644
--- a/it_url.class
+++ b/it_url.class
@@ -226,6 +226,7 @@ static function curl_opts($p=array())
* @param $p['data'] POST data array with key-value pairs
* @param $p['files'] [fieldname => filename] of files to upload
* @param $p['method'] different HTTP method
+ * @param $p['verbose'] generate and capture curl verbose output in $this->verbose and alert mails
*/
function request($p=array())
@@ -237,6 +238,10 @@ function request($p=array())
$url->headers = array();
$p['headers'] = (array)$p['headers'] + self::_default_headers($url, $p);
$opts = array(CURLOPT_HEADER => 1) + self::curl_opts($p + array('user' => $this->user, 'pass' => $this->pass, 'followlocation' => false));
+ if ($p['verbose']) {
+ $stderr = it::fopen("php://memory", "r+");
+ $opts += [CURLOPT_STDERR => $stderr, CURLOPT_VERBOSE => 1];
+ }
$curl = curl_init($url->url);
curl_setopt_array($curl, $opts);
@@ -265,8 +270,15 @@ function request($p=array())
$this->curlinfo = curl_getinfo($curl);
}
- if ($got === false && $p['retries'] <= 0)
- it::error((array)$p['it_error'] + ['title' => "problem getting $url->url with curl: (" . curl_errno($curl) . ") " . curl_error($curl), 'body' => curl_getinfo($curl)]);
+ if ($p['verbose']) {
+ rewind($stderr);
+ $this->verbose = stream_get_contents($stderr);
+ fclose($stderr);
+ }
+
+ if ($got === false && $p['retries'] <= 0) {
+ it::error((array)$p['it_error'] + ['title' => "problem getting $url->url with curl: (" . curl_errno($curl) . ") " . curl_error($curl), 'body' => curl_getinfo($curl) + ($p['verbose'] ? ['verbose' => $this->verbose] : [])]);
+ }
return $result;
}