]> git.mxchange.org Git - friendica.git/commitdiff
Use rawContent for Special Options to avoid a protected options() method
authorPhilipp <admin@philipp.info>
Tue, 4 Jan 2022 19:47:17 +0000 (20:47 +0100)
committerPhilipp <admin@philipp.info>
Tue, 4 Jan 2022 19:59:29 +0000 (20:59 +0100)
src/App/Router.php
src/BaseModule.php
src/Module/Special/Options.php
tests/src/Module/Special/OptionsTest.php

index fd1cec362ff2947459dc9f8e2c750173a0f6e3fd..c21dfd44d9bbca290665a76c41da9c213a8f0b97 100644 (file)
@@ -262,7 +262,7 @@ class Router
 
                $this->parameters = [];
 
-               // Check if the HTTP method ist OPTIONS and return the special Options Module with the possible HTTP methods
+               // Check if the HTTP method is OPTIONS and return the special Options Module with the possible HTTP methods
                if ($this->args->getMethod() === static::OPTIONS) {
                        $routeOptions = $dispatcher->getOptions($cmd);
 
index c1a926a3a53f414cad8dcb097afc763620a12d94..5ac56533ca94e465f4e3ac5c4dbd2ec99723e3fb 100644 (file)
@@ -173,18 +173,6 @@ abstract class BaseModule implements ICanHandleRequests
        {
        }
 
-       /**
-        * Module OPTIONS method to process submitted data
-        *
-        * Extend this method if the module is supposed to process OPTIONS requests.
-        * Doesn't display any content
-        *
-        * @param string[] $request The $_REQUEST content
-        */
-       protected function options(array $request = [])
-       {
-       }
-
        /**
         * {@inheritDoc}
         */
@@ -237,9 +225,6 @@ abstract class BaseModule implements ICanHandleRequests
                        case Router::PUT:
                                $this->put($request);
                                break;
-                       case Router::OPTIONS:
-                               $this->options($request);
-                               break;
                }
 
                $timestamp = microtime(true);
index 389e7a239de89a1432e104f23d90fe1ad168184f..79ce5d0c2ed9fc75fb8274d5caf34c102e5a9f2c 100644 (file)
@@ -34,13 +34,9 @@ use Friendica\Module\Response;
  */
 class Options extends BaseModule
 {
-       protected function options(array $request = [])
+       protected function rawContent(array $request = [])
        {
-               $allowedMethods = $this->parameters['AllowedMethods'] ?? [];
-
-               if (empty($allowedMethods)) {
-                       $allowedMethods = Router::ALLOWED_METHODS;
-               }
+               $allowedMethods = $this->parameters['AllowedMethods'] ?? Router::ALLOWED_METHODS;
 
                // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
                $this->response->setHeader(implode(',', $allowedMethods), 'Allow');
index ab85e7f8ca9dd29befb471d11087a79263c3db8c..460435ae24d2a3a9995f390abae03effb419bd31 100644 (file)
@@ -40,7 +40,6 @@ class OptionsTest extends FixtureTest
                self::assertEquals([
                        'Allow'                       => [implode(',', [Router::GET, Router::POST])],
                        ICanCreateResponses::X_HEADER => ['blank'],
-                       'Content-Type'
                ], $response->getHeaders());
                self::assertEquals(implode(',', [Router::GET, Router::POST]), $response->getHeaderLine('Allow'));
        }