Fix App routing
This commit is contained in:
parent
543e4be0a6
commit
37f850377e
4 changed files with 14 additions and 10 deletions
|
@ -710,8 +710,7 @@ class App
|
||||||
$timestamp = microtime(true);
|
$timestamp = microtime(true);
|
||||||
$response = $module->run($input);
|
$response = $module->run($input);
|
||||||
$this->profiler->set(microtime(true) - $timestamp, 'content');
|
$this->profiler->set(microtime(true) - $timestamp, 'content');
|
||||||
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML &&
|
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
|
||||||
$response->getStatusCode() == 200) {
|
|
||||||
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
|
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
|
||||||
} else {
|
} else {
|
||||||
$page->exit($response);
|
$page->exit($response);
|
||||||
|
|
|
@ -36,13 +36,15 @@ interface ICanCreateResponses
|
||||||
const TYPE_JSON = 'json';
|
const TYPE_JSON = 'json';
|
||||||
const TYPE_ATOM = 'atom';
|
const TYPE_ATOM = 'atom';
|
||||||
const TYPE_RSS = 'rss';
|
const TYPE_RSS = 'rss';
|
||||||
|
const TYPE_BLANK = 'blank';
|
||||||
|
|
||||||
const ALLOWED_TYPES = [
|
const ALLOWED_TYPES = [
|
||||||
self::TYPE_HTML,
|
self::TYPE_HTML,
|
||||||
self::TYPE_XML,
|
self::TYPE_XML,
|
||||||
self::TYPE_JSON,
|
self::TYPE_JSON,
|
||||||
self::TYPE_ATOM,
|
self::TYPE_ATOM,
|
||||||
self::TYPE_RSS
|
self::TYPE_RSS,
|
||||||
|
self::TYPE_BLANK,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Special;
|
||||||
|
|
||||||
use Friendica\App\Router;
|
use Friendica\App\Router;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Module\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the allowed HTTP methods based on the route information
|
* Returns the allowed HTTP methods based on the route information
|
||||||
|
@ -44,5 +45,6 @@ class Options extends BaseModule
|
||||||
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
|
||||||
$this->response->setHeader(implode(',', $allowedMethods), 'Allow');
|
$this->response->setHeader(implode(',', $allowedMethods), 'Allow');
|
||||||
$this->response->setStatus(204);
|
$this->response->setStatus(204);
|
||||||
|
$this->response->setType(Response::TYPE_BLANK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class OptionsTest extends FixtureTest
|
||||||
self::assertEquals('No Content', $response->getReasonPhrase());
|
self::assertEquals('No Content', $response->getReasonPhrase());
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'Allow' => [implode(',', Router::ALLOWED_METHODS)],
|
'Allow' => [implode(',', Router::ALLOWED_METHODS)],
|
||||||
ICanCreateResponses::X_HEADER => ['html'],
|
ICanCreateResponses::X_HEADER => ['blank'],
|
||||||
], $response->getHeaders());
|
], $response->getHeaders());
|
||||||
self::assertEquals(implode(',', Router::ALLOWED_METHODS), $response->getHeaderLine('Allow'));
|
self::assertEquals(implode(',', Router::ALLOWED_METHODS), $response->getHeaderLine('Allow'));
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ class OptionsTest extends FixtureTest
|
||||||
self::assertEquals('No Content', $response->getReasonPhrase());
|
self::assertEquals('No Content', $response->getReasonPhrase());
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'Allow' => [implode(',', [Router::GET, Router::POST])],
|
'Allow' => [implode(',', [Router::GET, Router::POST])],
|
||||||
ICanCreateResponses::X_HEADER => ['html'],
|
ICanCreateResponses::X_HEADER => ['blank'],
|
||||||
|
'Content-Type'
|
||||||
], $response->getHeaders());
|
], $response->getHeaders());
|
||||||
self::assertEquals(implode(',', [Router::GET, Router::POST]), $response->getHeaderLine('Allow'));
|
self::assertEquals(implode(',', [Router::GET, Router::POST]), $response->getHeaderLine('Allow'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue