$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($this->args->getQueryString(), 0, 9) == 'nodeinfo/') {
+ $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($this->args->getQueryString(), 0, 8) == 'profile/') {
$this->response->setHeader('*', 'Access-Control-Allow-Origin');
$this->response->setHeader('*', 'Access-Control-Allow-Headers');
public function httpError(int $httpCode, string $message = '', $content = '')
{
if ($httpCode >= 400) {
- $this->logger->debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'callstack' => System::callstack(20), 'method' => $this->args->getMethod(), 'agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
+ $this->logger->debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => $this->args->getMethod(), 'agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
}
$this->response->setStatus($httpCode, $message);
{
$this->httpExit(json_encode($content, $options), ICanCreateResponses::TYPE_JSON, $content_type);
}
+
+ /**
+ * Display a non-200 HTTP code response using JSON to encode the content and exit
+ *
+ * @param int $httpCode
+ * @param mixed $content
+ * @param string $content_type
+ * @return void
+ * @throws HTTPException\InternalServerErrorException
+ */
+ public function jsonError(int $httpCode, $content, string $content_type = 'application/json')
+ {
+ if ($httpCode >= 400) {
+ $this->logger->debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => $this->args->getMethod(), 'agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
+ }
+
+ $this->response->setStatus($httpCode);
+ $this->jsonExit($content, $content_type);
+ }
}