سؤال

I have a page that loads another page in it via cURL. Similar to this:

function get_data($url) {
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}
echo get_data($_GET["url"]);

How can I estimate the amount of traffic of each request ? Say, user wants to display imdb.com at my page, I want to know how much of my server's bandwidth was used at this request (including images and all css/js files that were passed).

هل كانت مفيدة؟

المحلول

Its kinda simple actually

curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);

http://php.net/manual/en/function.curl-getinfo.php

نصائح أخرى

echo curl_getinfo($ch, CURLINFO_REQUEST_SIZE);

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top