Return redirect_url as part of the return array from z_fetch_url instead of via global state
This commit is contained in:
parent
50d4d37609
commit
930da0aa44
1 changed files with 1 additions and 2 deletions
|
@ -158,13 +158,11 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
$a->set_curl_redirect_url($newurl);
|
|
||||||
return z_fetch_url($newurl,$binary, $redirects, $opts);
|
return z_fetch_url($newurl,$binary, $redirects, $opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$a->set_curl_redirect_url($url);
|
|
||||||
$a->set_curl_code($http_code);
|
$a->set_curl_code($http_code);
|
||||||
$a->set_curl_content_type($curl_info['content_type']);
|
$a->set_curl_content_type($curl_info['content_type']);
|
||||||
|
|
||||||
|
@ -175,6 +173,7 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
|
||||||
$rc = intval($http_code);
|
$rc = intval($http_code);
|
||||||
$ret['return_code'] = $rc;
|
$ret['return_code'] = $rc;
|
||||||
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
|
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
|
||||||
|
$ret['redirect_url'] = $url;
|
||||||
if(! $ret['success']) {
|
if(! $ret['success']) {
|
||||||
$ret['error'] = curl_error($ch);
|
$ret['error'] = curl_error($ch);
|
||||||
$ret['debug'] = $curl_info;
|
$ret['debug'] = $curl_info;
|
||||||
|
|
Loading…
Reference in a new issue