This has been solved, by adding the following to the CURL request:
curl_setopt($ch, CURLOPT_HEADER, false);
This is weird as this setting has nothing to do with anything related to double processing of a CURL request. However, by adding this to the script, the duplicates stopped being created.