]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Salmon.php
Merge remote-tracking branch 'upstream/develop' into network-thread-view
[friendica.git] / src / Protocol / Salmon.php
index 77084591022b0fa2f994ab893dbc23de53d06228..95bddcd6553b5d6c4e0efb7e428d5c6de086466d 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
  *
@@ -22,9 +22,9 @@
 namespace Friendica\Protocol;
 
 use Friendica\Core\Logger;
+use Friendica\DI;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
-use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
 
@@ -72,7 +72,7 @@ class Salmon
                                                $ret[$x] = substr($ret[$x], 5);
                                        }
                                } elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
-                                       $ret[$x] = Network::fetchUrl($ret[$x]);
+                                       $ret[$x] = DI::httpClient()->fetch($ret[$x]);
                                }
                        }
                }
@@ -155,9 +155,9 @@ class Salmon
                $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
 
                // slap them
-               $postResult = Network::post($url, $salmon, [
-                       'Content-typeapplication/magic-envelope+xml',
-                       'Content-length: ' . strlen($salmon)
+               $postResult = DI::httpClient()->post($url, $salmon, [
+                       'Content-type' => 'application/magic-envelope+xml',
+                       'Content-length' => strlen($salmon),
                ]);
 
                $return_code = $postResult->getReturnCode();
@@ -180,9 +180,9 @@ class Salmon
                        $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
 
                        // slap them
-                       $postResult = Network::post($url, $salmon, [
-                               'Content-typeapplication/magic-envelope+xml',
-                               'Content-length: ' . strlen($salmon)
+                       $postResult = DI::httpClient()->post($url, $salmon, [
+                               'Content-type' => 'application/magic-envelope+xml',
+                               'Content-length' => strlen($salmon),
                        ]);
                        $return_code = $postResult->getReturnCode();
                }
@@ -203,9 +203,9 @@ class Salmon
                        $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
 
                        // slap them
-                       $postResult = Network::post($url, $salmon, [
-                               'Content-typeapplication/magic-envelope+xml',
-                               'Content-length: ' . strlen($salmon)]);
+                       $postResult = DI::httpClient()->post($url, $salmon, [
+                               'Content-type' => 'application/magic-envelope+xml',
+                               'Content-length' => strlen($salmon)]);
                        $return_code = $postResult->getReturnCode();
                }
 
@@ -215,7 +215,7 @@ class Salmon
                        return -1;
                }
 
-               if (($return_code == 503) && (stristr($postResult->getHeader(), 'retry-after'))) {
+               if (($return_code == 503) && $postResult->inHeader('retry-after')) {
                        return -1;
                }
 
@@ -229,7 +229,7 @@ class Salmon
         */
        public static function salmonKey($pubkey)
        {
-               Crypto::pemToMe($pubkey, $m, $e);
-               return 'RSA' . '.' . Strings::base64UrlEncode($m, true) . '.' . Strings::base64UrlEncode($e, true);
+               Crypto::pemToMe($pubkey, $modulus, $exponent);
+               return 'RSA' . '.' . Strings::base64UrlEncode($modulus, true) . '.' . Strings::base64UrlEncode($exponent, true);
        }
 }