Merge pull request #6235 from annando/curl-notice

Avoids the notice "array_merge(): Argument #1 is not an array"
This commit is contained in:
Hypolite Petovan 2018-12-05 01:41:22 -05:00 committed by GitHub
commit 8416dea3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,11 +161,21 @@ class CurlResult
if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
$redirect_parts = parse_url(defaults($this->info, 'redirect_url', ''));
if (empty($redirect_parts)) {
$redirect_parts = [];
}
if (preg_match('/(Location:|URI:)(.*?)\n/i', $this->header, $matches)) {
$redirect_parts = array_merge($redirect_parts, parse_url(trim(array_pop($matches))));
$redirect_parts2 = parse_url(trim(array_pop($matches)));
if (!empty($redirect_parts2)) {
$redirect_parts = array_merge($redirect_parts, $redirect_parts2);
}
}
$parts = parse_url(defaults($this->info, 'url', ''));
if (empty($parts)) {
$parts = [];
}
/// @todo Checking the corresponding RFC which parts of a redirect can be ommitted.
$components = ['scheme', 'host', 'path', 'query', 'fragment'];