title: cURL size limit of get
body: <p>I want to know if there is any way to get only a particular amount of data through cURL?</p>
  
  <p>Option 1:<br>
  <code>curl_setopt ($curl_handle, CURLOPT_HTTPHEADER, array("Range: bytes=0-1000"));
  </code> but Its not supported by all servers</p>
  
  <p>Option 2:<br>
  <a href="https://stackoverflow.com/questions/3431703/having-trouble-limiting-download-size-of-phps-curl-function">Having trouble limiting download size of PHP&#39;s cURL function</a> but this function is giving me error <code>Failed writing body (0 != 11350)</code> and reading for which I found that many say its a bug.</p>
  
  <p>So following the above <code>write_function</code> I tried to <code>curl_close($handle)</code> instead of <code>returning 0</code> but this throws an error <code>Attempt to close cURL handle from a callback</code>   </p>
  
  <p>Now the only way I can think of is parsing headers for content length <code>but this will eventually result in 2 requests ??</code> first getting headers with <code>CURLOPT_NOBODY</code> then getting full content?</p>