From 543e4be0a61adf0f7717d91dc4436a7be9725ad0 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 3 Jan 2022 19:30:27 +0100 Subject: [PATCH] Replace 'REQUEST_METHOD' with App\Arguments::getMethod() --- mod/pubsub.php | 2 +- mod/pubsubhubbub.php | 2 +- src/Core/System.php | 4 ++-- src/Util/HTTPSignature.php | 6 ++---- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mod/pubsub.php b/mod/pubsub.php index 7d5c70a54c..e07b15583c 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -53,7 +53,7 @@ function pubsub_init(App $a) $nick = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : ''); $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 ); - if ($_SERVER['REQUEST_METHOD'] === 'GET') { + if (DI::args()->getMethod() === App\Router::GET) { $hub_mode = trim($_GET['hub_mode'] ?? ''); $hub_topic = trim($_GET['hub_topic'] ?? ''); $hub_challenge = trim($_GET['hub_challenge'] ?? ''); diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index 583167bbb0..361cb0a597 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -43,7 +43,7 @@ function pubsubhubbub_init(App $a) { // [hub_secret] => af11... // [hub_topic] => http://friendica.local/dfrn_poll/sazius - if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (DI::args()->getMethod() === App\Router::POST) { $hub_mode = $_POST['hub_mode'] ?? ''; $hub_callback = $_POST['hub_callback'] ?? ''; $hub_verify_token = $_POST['hub_verify_token'] ?? ''; diff --git a/src/Core/System.php b/src/Core/System.php index fa38703139..8a9cdfb96b 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -312,7 +312,7 @@ class System public static function httpExit($val, $message = '', $content = '') { if ($val >= 400) { - Logger::debug('Exit with error', ['code' => $val, 'message' => $message, 'callstack' => System::callstack(20), 'method' => $_SERVER['REQUEST_METHOD'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']); + Logger::debug('Exit with error', ['code' => $val, 'message' => $message, 'callstack' => System::callstack(20), 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']); } header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $message); DI::page()->exit(DI::apiResponse()->generate()); @@ -324,7 +324,7 @@ class System public static function jsonError($httpCode, $data, $content_type = 'application/json') { if ($httpCode >= 400) { - Logger::debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'callstack' => System::callstack(20), 'method' => $_SERVER['REQUEST_METHOD'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']); + Logger::debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'callstack' => System::callstack(20), 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']); } header($_SERVER["SERVER_PROTOCOL"] . ' ' . $httpCode); self::jsonExit($data, $content_type); diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index de0ee93511..3e22820e5c 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -28,9 +28,7 @@ use Friendica\DI; use Friendica\Model\APContact; use Friendica\Model\Contact; use Friendica\Model\User; -use Friendica\Network\HTTPClient\Response\CurlResult; use Friendica\Network\HTTPClient\Client\HttpClientOptions; -use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses; /** * Implements HTTP Signatures per draft-cavage-http-signatures-07. @@ -66,7 +64,7 @@ class HTTPSignature // Decide if $data arrived via controller submission or curl. $headers = []; - $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']).' '.$_SERVER['REQUEST_URI']; + $headers['(request-target)'] = strtolower(DI::args()->getMethod()).' '.$_SERVER['REQUEST_URI']; foreach ($_SERVER as $k => $v) { if (strpos($k, 'HTTP_') === 0) { @@ -493,7 +491,7 @@ class HTTPSignature } $headers = []; - $headers['(request-target)'] = strtolower($http_headers['REQUEST_METHOD']) . ' ' . parse_url($http_headers['REQUEST_URI'], PHP_URL_PATH); + $headers['(request-target)'] = strtolower(DI::args()->getMethod()) . ' ' . parse_url($http_headers['REQUEST_URI'], PHP_URL_PATH); // First take every header foreach ($http_headers as $k => $v) {