1
0
Fork 0

Making the tests happy

This commit is contained in:
Michael 2018-11-24 09:01:10 +00:00
parent 586c7fb29a
commit 167ff0eb71

View file

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