curl_getinfo returning -1 as content-length
I am building a website crawler and using a cURL class with these options for getting headers, so that I can extract their mime/type
and c开发者_如何学运维ontent-length
before downloading full site to very it as text/html
and below specified size limits.
these are my curl options
$c->setopt(CURLOPT_URL, $theURL);
$c->setopt(CURLOPT_HEADER, false);
$c->setopt(CURLOPT_RETURNTRANSFER, true);
$c->setopt(CURLOPT_TIMEOUT, 10);
$c->setopt(CURLOPT_CONNECTTIMEOUT, 10);
$c->setopt(CURLOPT_NOBODY, TRUE);
$c->setopt(CURLOPT_FOLLOWLOCATION, TRUE);
$c->setopt(CURLOPT_MAXREDIRS, 2);
// Within Class
$theReturnValue = curl_exec($this->m_handle);
$this->m_status = curl_getinfo($this->m_handle) ;
but it always return [download_content_length] => -1
even without CURLOPT_NOBODY
however the data (whole file) retrived is correct.
The libcurl docs for CURLINFO_CONTENT_LENGTH_DOWNLOAD (which is what the PHP binding is using) says:
"this returns -1 if the size isn't known"
精彩评论