]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/CurlResult.php
Refactor User::getAvatarUrlForId into getAvatarUrl
[friendica.git] / src / Network / CurlResult.php
index 1187e45eb6f903fc7b73cbb423d446dbe5e64214..8b3b12876a9ba74a49588164fdb3635a70e8db94 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
  *
@@ -167,7 +167,6 @@ class CurlResult implements IHTTPResult
                }
 
                if (!$this->isSuccess) {
-                       Logger::notice('http error', ['url' => $this->url, 'code' => $this->returnCode, 'error'  => $this->error, 'callstack' => System::callstack(20)]);
                        Logger::debug('debug', ['info' => $this->info]);
                }
 
@@ -242,21 +241,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 +288,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 +322,6 @@ class CurlResult implements IHTTPResult
                return $this->body;
        }
 
-       /** {@inheritDoc} */
-       public function getInfo()
-       {
-               return $this->info;
-       }
-
        /** {@inheritDoc} */
        public function isRedirectUrl()
        {