diff options
author | Olaf Conradi <olaf@conradi.org> | 2012-12-26 18:44:30 +0100 |
---|---|---|
committer | Olaf Conradi <olaf@conradi.org> | 2012-12-26 18:44:30 +0100 |
commit | a5cbea038e1f4aff61e3c761ca8b25f8dd674609 (patch) | |
tree | 5c8af9eaeb7092a93c10653137042d8b180d6c68 | |
parent | 7f13baf367e53a4222c068d81557d6618e6292ff (diff) | |
download | volse-hubzilla-a5cbea038e1f4aff61e3c761ca8b25f8dd674609.tar.gz volse-hubzilla-a5cbea038e1f4aff61e3c761ca8b25f8dd674609.tar.bz2 volse-hubzilla-a5cbea038e1f4aff61e3c761ca8b25f8dd674609.zip |
Tweak behavior of redirect for http codes
Not every webserver supports 308 redirects with POST correctly.
Most sites are already configured using 301 or 302 redirects.
This only effects POST, GET behavior is unmodified.
Most calls to POST are under control by friendica not the end user,
so should not be a problem ni general.
GET with 301, 302, 303, 307 and 308 are redirected as GET
POST with 301, 302, 307 and 308 are redirected as POST
POST with 303 is redirected as GET
-rw-r--r-- | include/network.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/include/network.php b/include/network.php index 6ef1c2605..321eb375f 100644 --- a/include/network.php +++ b/include/network.php @@ -172,10 +172,10 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) if (isset($url_parsed)) { $redirects++; @curl_close($ch); - if($http_code == 307 || $http_code == 308) { - return post_url($newurl,$params,$redirects,$timeout); - } else { + if($http_code == 303) { return fetch_url($newurl,false,$redirects,$timeout); + } else { + return post_url($newurl,$params,$redirects,$timeout); } } } @@ -355,11 +355,10 @@ function z_post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0 if (isset($url_parsed)) { $redirects++; curl_close($ch); - if($http_code == 307 || $http_code == 308) { - return z_post_url($newurl,$params,$headers,$redirects,$timeout); - } else { - logger("params=".print_r($params, true)); + if($http_code == 303) { return z_fetch_url($newurl,false,$headers,$redirects,$timeout); + } else { + return z_post_url($newurl,$params,$headers,$redirects,$timeout); } } } |