]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/CurlResult.php
Merge pull request #10632 from annando/fox-notifications
[friendica.git] / src / Network / CurlResult.php
index 072ab15c277ade82f95162191a27d5eaec8c4f5c..1c74634db48d2b67a55bf286b82160360af206be 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -101,7 +101,7 @@ class CurlResult implements IHTTPResult
         *
         * @param string $url optional URL
         *
-        * @return CurlResult a CURL with error response
+        * @return IHTTPResult a CURL with error response
         * @throws InternalServerErrorException
         */
        public static function createErrorCurl($url = '')
@@ -242,21 +242,27 @@ class CurlResult implements IHTTPResult
        }
 
        /** {@inheritDoc} */
-       public function getHeader(string $field = '')
+       public function getHeader($header)
        {
-               if (empty($field)) {
-                       return $this->header;
+               if (empty($header)) {
+                       return [];
                }
 
-               $field = strtolower(trim($field));
+               $header = strtolower(trim($header));
 
                $headers = $this->getHeaderArray();
 
-               if (isset($headers[$field])) {
-                       return $headers[$field];
+               if (isset($headers[$header])) {
+                       return $headers[$header];
                }
 
-               return '';
+               return [];
+       }
+
+       /** {@inheritDoc} */
+       public function getHeaders()
+       {
+               return $this->getHeaderArray();
        }
 
        /** {@inheritDoc} */
@@ -283,7 +289,11 @@ class CurlResult implements IHTTPResult
                        $parts = explode(':', $line);
                        $headerfield = strtolower(trim(array_shift($parts)));
                        $headerdata = trim(implode(':', $parts));
-                       $this->header_fields[$headerfield] = $headerdata;
+                       if (empty($this->header_fields[$headerfield])) {
+                               $this->header_fields[$headerfield] = [$headerdata];
+                       } elseif (!in_array($headerdata, $this->header_fields[$headerfield])) {
+                               $this->header_fields[$headerfield][] = $headerdata;
+                       }
                }
 
                return $this->header_fields;
@@ -313,12 +323,6 @@ class CurlResult implements IHTTPResult
                return $this->body;
        }
 
-       /** {@inheritDoc} */
-       public function getInfo()
-       {
-               return $this->info;
-       }
-
        /** {@inheritDoc} */
        public function isRedirectUrl()
        {