1

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).

ilya_i
  • 333
  • 5
  • 14

2 Answers2

1

echo curl_getinfo($ch, CURLINFO_REQUEST_SIZE);

Rob
  • 12,659
  • 4
  • 39
  • 56
1

Its kinda simple actually

curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);

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

Danilo Kobold
  • 2,562
  • 1
  • 21
  • 31