]> git.mxchange.org Git - friendica.git/commitdiff
Fix OPTIONS
authorPhilipp <admin@philipp.info>
Sun, 2 Jan 2022 21:17:04 +0000 (22:17 +0100)
committerPhilipp <admin@philipp.info>
Tue, 4 Jan 2022 19:59:25 +0000 (20:59 +0100)
src/App/Page.php
src/BaseModule.php
src/Module/Response.php
tests/src/Module/Special/OptionsTest.php

index 57468f8e5e988e90152db9703a8963dc01afe33e..9e59ab9ae7aeaf6303f605ada1fa51ba4e9b5685 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
 use Friendica\Core\Theme;
+use Friendica\DI;
 use Friendica\Network\HTTPException;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
@@ -378,7 +379,7 @@ class Page implements ArrayAccess
         */
        public function exit(ResponseInterface $response)
        {
-               header(sprintf("HTTP/%s %i %s",
+               header(sprintf("HTTP/%s %s %s",
                        $response->getProtocolVersion(),
                        $response->getStatusCode(),
                        $response->getReasonPhrase())
index 4fbf39cf714865f2c6f7b9ae1e3ad52a8fb795f0..ae3b7214095a350d3ef18c2424b4b6afd3702157 100644 (file)
@@ -191,23 +191,23 @@ abstract class BaseModule implements ICanHandleRequests
        public function run(array $request = []): ResponseInterface
        {
                // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb
-               if (substr($request['pagename'] ?? '', 0, 12) == '.well-known/') {
+               if (substr($this->args->getQueryString(), 0, 12) == '.well-known/') {
                        $this->response->setHeader('*', 'Access-Control-Allow-Origin');
                        $this->response->setHeader('*', 'Access-Control-Allow-Headers');
                        $this->response->setHeader(Router::GET, 'Access-Control-Allow-Methods');
                        $this->response->setHeader('false', 'Access-Control-Allow-Credentials');
-               } elseif (substr($request['pagename'] ?? '', 0, 8) == 'profile/') {
+               } elseif (substr($this->args->getQueryString(), 0, 8) == 'profile/') {
                        $this->response->setHeader('*', 'Access-Control-Allow-Origin');
                        $this->response->setHeader('*', 'Access-Control-Allow-Headers');
                        $this->response->setHeader(Router::GET, 'Access-Control-Allow-Methods');
                        $this->response->setHeader('false', 'Access-Control-Allow-Credentials');
-               } elseif (substr($request['pagename'] ?? '', 0, 4) == 'api/') {
+               } elseif (substr($this->args->getQueryString(), 0, 4) == 'api/') {
                        $this->response->setHeader('*', 'Access-Control-Allow-Origin');
                        $this->response->setHeader('*', 'Access-Control-Allow-Headers');
                        $this->response->setHeader(implode(',', Router::ALLOWED_METHODS), 'Access-Control-Allow-Methods');
                        $this->response->setHeader('false', 'Access-Control-Allow-Credentials');
                        $this->response->setHeader('Link', 'Access-Control-Expose-Headers');
-               } elseif (substr($request['pagename'] ?? '', 0, 11) == 'oauth/token') {
+               } elseif (substr($this->args->getQueryString(), 0, 11) == 'oauth/token') {
                        $this->response->setHeader('*', 'Access-Control-Allow-Origin');
                        $this->response->setHeader('*', 'Access-Control-Allow-Headers');
                        $this->response->setHeader(Router::POST, 'Access-Control-Allow-Methods');
index e4bfde7a3c6d949c6c0ad72dca685ef29e987f4c..db30a10d8cf7cf487777a8cad5343e92d797b354 100644 (file)
@@ -140,6 +140,6 @@ class Response implements ICanCreateResponses
                // Setting the response type as an X-header for direct usage
                $this->headers[static::X_HEADER] = $this->type;
 
-               return new \GuzzleHttp\Psr7\Response($this->status, $this->headers, $this->content, $this->reason);
+               return new \GuzzleHttp\Psr7\Response($this->status, $this->headers, $this->content, '1.1', $this->reason);
        }
 }
index 3f7024f2dbead0ecb93ccb27f222bd67d4d5ec2f..ea5982e655427bd4e9d8ad7a5ce74cb6bacc9e31 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Friendica\Test\src\Module\Special;
 
+use Friendica\App\Arguments;
+use Friendica\App\Page;
 use Friendica\App\Router;
 use Friendica\Capabilities\ICanCreateResponses;
 use Friendica\DI;