1
0
Fork 0

Auto-disable misbehaving curl downloader on php 5, refs #9002

pull/9379/head
Jordi Boggiano 2020-10-29 22:39:26 +01:00
parent 51685580c7
commit 472f78bff1
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 21 additions and 1 deletions

View File

@ -80,7 +80,27 @@ class HttpDownloader
list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
$this->wait($job['id']);
return $this->getResponse($job['id']);
$response = $this->getResponse($job['id']);
// check for failed curl response (empty body but successful looking response)
if (
$this->curl
&& PHP_VERSION_ID < 70000
&& $response->getBody() === null
&& $response->getStatusCode() === 200
&& $response->getHeader('content-length') !== '0'
) {
$this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
$this->curl = null;
list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
$this->wait($job['id']);
$response = $this->getResponse($job['id']);
}
return $response;
}
public function add($url, $options = array())