I'm using CURL and a proxy to grab some xml files, occasionally only part of the XML document comes through and fails when I try to load/use the xml (simplexml_load_string).
I thought something like..
if(curl_errno($ch))
{
$error = curl_error($ch);
// handle error
}
would catch this sorta error via CURL errno..
CURLE_PARTIAL_FILE (18)
A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that doesn't match the previously given size.
However, this does not work, I think it might be due to using a proxy. Anything else I can check? My only thought now is to do a preg_match for the last bit of the XML document, but that seems less than ideal as I'm getting multiple types of XML documents and I'd have to write checks for each type.