$timestamp = microtime(true);
$response = $module->run($input);
$this->profiler->set(microtime(true) - $timestamp, 'content');
- if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML &&
- $response->getStatusCode() == 200) {
+ if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
} else {
$page->exit($response);
*/
const X_HEADER = 'X-RESPONSE-TYPE';
- const TYPE_HTML = 'html';
- const TYPE_XML = 'xml';
- const TYPE_JSON = 'json';
- const TYPE_ATOM = 'atom';
- const TYPE_RSS = 'rss';
+ const TYPE_HTML = 'html';
+ const TYPE_XML = 'xml';
+ const TYPE_JSON = 'json';
+ const TYPE_ATOM = 'atom';
+ const TYPE_RSS = 'rss';
+ const TYPE_BLANK = 'blank';
const ALLOWED_TYPES = [
self::TYPE_HTML,
self::TYPE_XML,
self::TYPE_JSON,
self::TYPE_ATOM,
- self::TYPE_RSS
+ self::TYPE_RSS,
+ self::TYPE_BLANK,
];
/**
use Friendica\App\Router;
use Friendica\BaseModule;
+use Friendica\Module\Response;
/**
* Returns the allowed HTTP methods based on the route information
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
$this->response->setHeader(implode(',', $allowedMethods), 'Allow');
$this->response->setStatus(204);
+ $this->response->setType(Response::TYPE_BLANK);
}
}
self::assertEquals('No Content', $response->getReasonPhrase());
self::assertEquals([
'Allow' => [implode(',', Router::ALLOWED_METHODS)],
- ICanCreateResponses::X_HEADER => ['html'],
+ ICanCreateResponses::X_HEADER => ['blank'],
], $response->getHeaders());
self::assertEquals(implode(',', Router::ALLOWED_METHODS), $response->getHeaderLine('Allow'));
}
self::assertEquals('No Content', $response->getReasonPhrase());
self::assertEquals([
'Allow' => [implode(',', [Router::GET, Router::POST])],
- ICanCreateResponses::X_HEADER => ['html'],
+ ICanCreateResponses::X_HEADER => ['blank'],
+ 'Content-Type'
], $response->getHeaders());
self::assertEquals(implode(',', [Router::GET, Router::POST]), $response->getHeaderLine('Allow'));
}