diff options
author | Olaf Conradi <olaf@conradi.org> | 2012-12-26 04:03:12 +0100 |
---|---|---|
committer | Olaf Conradi <olaf@conradi.org> | 2012-12-26 04:03:12 +0100 |
commit | bb16186fabdbd4b49ad4ff13552d97a0462e298a (patch) | |
tree | 29d7c217fbac281b1b958f7223a52d908c9f1c2d | |
parent | e15683175e0582757746534044e5893ab70f4724 (diff) | |
download | volse-hubzilla-bb16186fabdbd4b49ad4ff13552d97a0462e298a.tar.gz volse-hubzilla-bb16186fabdbd4b49ad4ff13552d97a0462e298a.tar.bz2 volse-hubzilla-bb16186fabdbd4b49ad4ff13552d97a0462e298a.zip |
Add permanent redirect (308) http code
Add 308 http code next to 301, 302, 303 and 307.
Close curl session before returning on redirect.
Let post_url redirect using post_url, not fetch_url (which is
actually 308 behavior).
-rw-r--r-- | include/network.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/include/network.php b/include/network.php index 0f1420d61..5571285b4 100644 --- a/include/network.php +++ b/include/network.php @@ -72,7 +72,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_ $base = substr($base,strlen($chunk)); } - if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $newurl = trim(array_pop($matches)); @@ -81,6 +81,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_ $url_parsed = @parse_url($newurl); if (isset($url_parsed)) { $redirects++; + @curl_close($ch); return fetch_url($newurl,$binary,$redirects,$timeout); } } @@ -161,7 +162,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) $base = substr($base,strlen($chunk)); } - if($http_code == 301 || $http_code == 302 || $http_code == 303) { + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $newurl = trim(array_pop($matches)); @@ -170,7 +171,8 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) $url_parsed = @parse_url($newurl); if (isset($url_parsed)) { $redirects++; - return fetch_url($newurl,false,$redirects,$timeout); + @curl_close($ch); + return post_url($newurl,false,$redirects,$timeout); } } $a->set_curl_code($http_code); @@ -247,7 +249,7 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accep $base = substr($base,strlen($chunk)); } - if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $newurl = trim(array_pop($matches)); @@ -339,7 +341,7 @@ function z_post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0 $base = substr($base,strlen($chunk)); } - if($http_code == 301 || $http_code == 302 || $http_code == 303) { + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $newurl = trim(array_pop($matches)); |