Actually, there is a bug when the headers reading timeouts, the
headers are read into the data results !
This:
while($currentHeader = fgets($fp,$this->_maxlinelen)) { ... } $results = ''; do { $_data = fread($fp, $this->maxlength); if (strlen($_data) == 0) { ...
should be changed to that:
while($currentHeader = fgets($fp,$this->_maxlinelen)) { ... } // 4 lines added to fix problem that on timeout of header, and not timeout of read-data, data returned includes header: if ($currentHeader === false) { $this->status=-100; return false; } $results = ''; do { $_data = fread($fp, $this->maxlength); if (strlen($_data) == 0) { ...
Indeed, according to fgets() php.net specs, it returns false on errors
(like timeouts).
Otherwise it sometimes returns the http headers in the data.... !
Diff:
I've updated Snoopy with this check to catch this case, where the header fetch times out but the body succeeds, and pulls the headers into the body.
This is committed at revision 1.36 but not yet packaged up for release.