]> git.mxchange.org Git - friendica.git/commitdiff
Don't send the header
authorMichael <heluecht@pirati.ca>
Mon, 12 Dec 2022 03:13:24 +0000 (03:13 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 12 Dec 2022 03:13:24 +0000 (03:13 +0000)
src/Module/Api/Twitter/Followers/Lists.php
src/Module/Api/Twitter/Friends/Lists.php
src/Module/Api/Twitter/Friendships/Incoming.php
src/Module/BaseApi.php

index 930114c47bb37e0800856e91b3efbc2d5c141194..04bddf83cd6c0edc64cdf2408040e370a60131c3 100644 (file)
@@ -110,10 +110,10 @@ class Lists extends ContactEndpoint
                        $ids = array_reverse($ids);
                }
 
-               self::setLinkHeader();
-
                $return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
 
+               $this->response->setHeader(self::getLinkHeader());      
+
                $this->response->exit('lists', ['lists' => $return]);
        }
 }
index 45c46f64d75624034cfd33a055f967dda3fc0ac9..1abce5364690f62d80ecacaca843ad36bdd37aa4 100644 (file)
@@ -77,7 +77,7 @@ class Lists extends ContactEndpoint
                        }
                } else {
                        $params = ['order' => ['cid' => true], 'limit' => $count];
-       
+
                        $condition = ['relation-cid' => $cid, 'follows' => true];
 
                        $total_count = (int)DBA::count('contact-relation', $condition);
@@ -110,10 +110,10 @@ class Lists extends ContactEndpoint
                        $ids = array_reverse($ids);
                }
 
-               self::setLinkHeader();
-
                $return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
 
+               $this->response->setHeader(self::getLinkHeader());      
+
                $this->response->exit('lists', ['lists' => $return]);
        }
 }
index d34d79fae055c627f7bd55632424a0e47ad91620..89a7b4bcec486475d88aac27a9028cee6711af45 100644 (file)
@@ -21,7 +21,6 @@
 
 namespace Friendica\Module\Api\Twitter\Friendships;
 
-use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Module\Api\Twitter\ContactEndpoint;
 use Friendica\Module\BaseApi;
@@ -81,7 +80,7 @@ class Incoming extends ContactEndpoint
 
                $return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
 
-               self::setLinkHeader();
+               $this->response->setHeader(self::getLinkHeader());      
 
                $this->response->exit('incoming', ['incoming' => $return]);
        }
index 47557928a97c368eb564a397d0bf4417e8d97766..1d5249ac85f70481566d9d297e856fc9ddba2613 100644 (file)
@@ -139,13 +139,13 @@ class BaseApi extends BaseModule
        }
 
        /**
-        * Set the "link" header with "next" and "prev" links
-        * @return void
+        * Get the "link" header with "next" and "prev" links
+        * @return string
         */
-       protected static function setLinkHeader()
+       protected static function getLinkHeader(): string
        {
                if (empty(self::$boundaries)) {
-                       return;
+                       return '';
                }
 
                $request = self::$request;
@@ -164,7 +164,19 @@ class BaseApi extends BaseModule
                $prev = $command . '?' . http_build_query($prev_request);
                $next = $command . '?' . http_build_query($next_request);
 
-               header('Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"');
+               return 'Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"';
+       }
+
+       /**
+        * Set the "link" header with "next" and "prev" links
+        * @return void
+        */
+       protected static function setLinkHeader()
+       {
+               $header = self::getLinkHeader();
+               if (!empty($header)) {
+                       header($header);
+               }
        }
 
        /**