mirror of
https://github.com/friendica/friendica
synced 2025-04-19 09:10:12 +00:00
Move System::httpError to BaseModule->httpError
- This will ensure headers set in BaseModule->run will be carried in httpError scenarios - Deprecate httpError() method in Core\System
This commit is contained in:
parent
da1416c07f
commit
e424b7bacb
5 changed files with 35 additions and 11 deletions
|
@ -476,4 +476,23 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
|
||||
System::exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send HTTP status header and exit.
|
||||
*
|
||||
* @param integer $httpCode HTTP status result value
|
||||
* @param string $message Error message. Optional.
|
||||
* @param mixed $content Response body. Optional.
|
||||
* @throws \Exception
|
||||
*/
|
||||
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->response->setStatus($httpCode, $message);
|
||||
|
||||
$this->httpExit($content);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue