title: PHP CURLOPT_WRITEFUNCTION doesn't appear to be working
body: <p>I'm trying to read just one chunk of a stream of data using curl.</p>
  
  <p>Ideally I would like to just retreive the first image in the stream and write that to a jpg file. </p>
  
  <p>I'm attempting to do this using WRITEFUNCTION and returning -1 if the length of the stream > say  20000.</p>
  
  <pre><code>function receiveResponse($ch,$string) {
      $length = strlen($string);
      if($length &gt;= 20000) { return -1; }
      return $length;
  }
  
  $ch = curl_init('http://&lt;url&gt;/videostream.cgi');
  curl_setopt($ch, CURLOPT_USERPWD, '&lt;user&gt;:&lt;password&gt;');
  curl_setopt($ch, CURLOPT_WRITEFUNCTION, "receiveResponse");
  curl_setopt($ch, CURLOPT_FILE, $fh);
  curl_exec($ch);
  </code></pre>
  
  <p>However the stream just continues to write to the file which ends up getting larger and larger in file size. </p>
  
  <p>Am i doing something horribly wrong?</p>
  
  <p>Regards,</p>