Merge pull request #745 from mexon/redirect_fix
Appending URLs in case of redirect is incorrect
This commit is contained in:
commit
462f19ccf2
|
@ -93,7 +93,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
$newurl = trim(array_pop($matches));
|
$newurl = trim(array_pop($matches));
|
||||||
}
|
}
|
||||||
if(strpos($newurl,'/') === 0)
|
if(strpos($newurl,'/') === 0)
|
||||||
$newurl = $url . $newurl;
|
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
return fetch_url($newurl,$binary,$redirects,$timeout);
|
return fetch_url($newurl,$binary,$redirects,$timeout);
|
||||||
|
@ -188,7 +188,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
||||||
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
|
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
|
||||||
$newurl = trim(array_pop($matches));
|
$newurl = trim(array_pop($matches));
|
||||||
if(strpos($newurl,'/') === 0)
|
if(strpos($newurl,'/') === 0)
|
||||||
$newurl = $url . $newurl;
|
$newurl = $old_location_info["scheme"] . "://" . $old_location_info["host"] . $newurl;
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
return fetch_url($newurl,false,$redirects,$timeout);
|
return fetch_url($newurl,false,$redirects,$timeout);
|
||||||
|
|
Loading…
Reference in a new issue