Internet: explicitly assume return of curl_exec() is string after error checking

this is documented as string|bool, but it's actually string|false if CURLOPT_RETURNTRANSFER is set, and bool if not.
This commit is contained in:
Dylan K. Taylor 2020-04-15 12:02:38 +01:00
parent d246933e3e
commit 0c9d16f1ef

View File

@ -227,10 +227,10 @@ class Internet{
]);
try{
$raw = curl_exec($ch);
$error = curl_error($ch);
if($error !== ""){
throw new InternetException($error);
if($raw === false){
throw new InternetException(curl_error($ch));
}
if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set");
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$rawHeaders = substr($raw, 0, $headerSize);