note 125961 added to function.curl-exec
| From: | jpatta at digitalgamesystems dot com | Date: | Thu, 25 Mar 2021 15:21:12 +0000 |
| Subject: | note 125961 added to function.curl-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219326@lists.php.net to get a copy of this message | ||
If you are looking the debug curl_exec, you may wish to log its details, and analyze the various
time points during its execution.
before curl_exec:
<?php
// this will produce a curl log
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, fopen('/your/writable/app/logdir/curl.log',
'a+')); // a+ to append...
?>
after curl_exec, but before curl_close:
<?php
// this will extract the timing information
extract(curl_getinfo($curl)); // create metrics variables from getinfo
$appconnect_time = curl_getinfo($curl, CURLINFO_APPCONNECT_TIME); // request this time
explicitly
$downloadduration = number_format($total_time - $starttransfer_time, 9); // format, to get rid
of scientific notation
$namelookup_time = number_format($namelookup_time, 9);
$metrics = "CURL...: $url Time...: $total_time DNS: $namelookup_time Connect: $connect_time
SSL/SSH: $appconnect_time PreTransfer: $pretransfer_time StartTransfer: $starttransfer_time
Download: $downloadduration";
error_log($metrics); // write to php-fpm default www-error.log, or append it to same log as
above with file_put_contents(<filename>, $metrics, FILE_APPEND)
?>
Happy debugging
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.245 (proxied: 98.167.63.188)
----
Manual Page -- http://php.net/manual/en/function.curl-exec.php
Edit -- https://master.php.net/note/edit/125961
Del: integrated -- https://master.php.net/note/delete/125961/integrated
Del: useless -- https://master.php.net/note/delete/125961/useless
Del: bad code -- https://master.php.net/note/delete/125961/bad+code
Del: spam -- https://master.php.net/note/delete/125961/spam
Del: non-english -- https://master.php.net/note/delete/125961/non-english
Del: in docs -- https://master.php.net/note/delete/125961/in+docs
Del: other reasons-- https://master.php.net/note/delete/125961
Reject -- https://master.php.net/note/reject/125961
Search -- https://master.php.net/manage/user-notes.php