]> git.mxchange.org Git - friendica.git/commitdiff
Note the final URL used to retrieve content after all redirects
authorMatthew Exon <github.mexon@spamgourmet.com>
Mon, 25 Jan 2016 06:41:56 +0000 (07:41 +0100)
committerMatthew Exon <github.mexon@spamgourmet.com>
Mon, 25 Jan 2016 06:41:56 +0000 (07:41 +0100)
boot.php
include/network.php

index 2242ba476d85f06e811eb872b4f435f5c2625ec0..9ee0c98df71444bcc529a25b56dcb944c80d1ce3 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -526,6 +526,7 @@ class App {
        private $curl_code;
        private $curl_content_type;
        private $curl_headers;
+       private $curl_redirect_url;
 
        private $cached_profile_image;
        private $cached_profile_picdate;
@@ -909,6 +910,14 @@ class App {
                return $this->curl_headers;
        }
 
+       function set_curl_redirect_url($url) {
+               $this->curl_redirect_url = $url;
+       }
+
+       function get_curl_redirect_url() {
+               return $this->curl_redirect_url;
+       }
+
        function get_cached_avatar_image($avatar_image){
                return $avatar_image;
 
index cc267966e8fd7d562cf4be36df54cb996f3f9d7c..1fd3792753ccb1d6cda23b5235a6c6d86a7ed7a1 100644 (file)
@@ -136,6 +136,10 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
                $base = substr($base,strlen($chunk));
        }
 
+       $a->set_curl_code($http_code);
+       $a->set_curl_content_type($curl_info['content_type']);
+       $a->set_curl_headers($header);
+
        if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
                $new_location_info = @parse_url($curl_info["redirect_url"]);
                $old_location_info = @parse_url($curl_info["url"]);
@@ -154,16 +158,17 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
                if (filter_var($newurl, FILTER_VALIDATE_URL)) {
                        $redirects++;
                        @curl_close($ch);
+                       $a->set_curl_redirect_url($newurl);
                        return z_fetch_url($newurl,$binary, $redirects, $opts);
                }
        }
 
 
+       $a->set_curl_redirect_url($url);
        $a->set_curl_code($http_code);
        $a->set_curl_content_type($curl_info['content_type']);
 
        $body = substr($s,strlen($header));
-       $a->set_curl_headers($header);