mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Force 503 HTTP status code for maintenance mode on v1
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
76d1b11bc9
commit
42c5a60c29
2 changed files with 4 additions and 3 deletions
|
|
@ -21,8 +21,9 @@ class ApiHelper {
|
|||
/**
|
||||
* Respond to a call
|
||||
* @psalm-taint-escape html
|
||||
* @param int $httpStatusCode force the HTTP status code, only used for the special case of maintenance mode which return 503 even for v1
|
||||
*/
|
||||
public static function respond(int $statusCode, string $statusMessage, array $headers = []): void {
|
||||
public static function respond(int $statusCode, string $statusMessage, array $headers = [], ?int $httpStatusCode = null): void {
|
||||
$request = Server::get(IRequest::class);
|
||||
$format = $request->getParam('format', 'xml');
|
||||
if (self::isV2($request)) {
|
||||
|
|
@ -46,7 +47,7 @@ class ApiHelper {
|
|||
header($name . ': ' . $value);
|
||||
}
|
||||
|
||||
http_response_code($response->getStatus());
|
||||
http_response_code($httpStatusCode ?? $response->getStatus());
|
||||
|
||||
self::setContentType($format);
|
||||
$body = $response->render();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if (Util::needUpgrade()
|
|||
|| \OC::$server->getConfig()->getSystemValueBool('maintenance')) {
|
||||
// since the behavior of apps or remotes are unpredictable during
|
||||
// an upgrade, return a 503 directly
|
||||
ApiHelper::respond(503, 'Service unavailable', ['X-Nextcloud-Maintenance-Mode' => '1']);
|
||||
ApiHelper::respond(503, 'Service unavailable', ['X-Nextcloud-Maintenance-Mode' => '1'], 503);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue