Skip to content

Commit

Permalink
Add Content-Type response header for JSON responses
Browse files Browse the repository at this point in the history
Initial work in #90

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
  • Loading branch information
Altahrim committed Nov 9, 2023
1 parent 44beafb commit 347765d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.web.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function isAuthenticated(): bool {
if (isset($_POST['step'])) {
// mark step as failed
http_response_code(500);
header('Content-Type: application/json');
echo(json_encode(['proceed' => false, 'response' => $e->getMessage()]));
die();
}
Expand Down Expand Up @@ -154,6 +155,7 @@ public function isAuthenticated(): bool {
break;
}
$updater->endStep($step);
header('Content-Type: application/json');
echo(json_encode(['proceed' => true]));
} catch (UpdateException $e) {
$data = $e->getData();
Expand All @@ -169,6 +171,7 @@ public function isAuthenticated(): bool {
$updater->rollbackChanges($step);
}
http_response_code(500);
header('Content-Type: application/json');
echo(json_encode(['proceed' => false, 'response' => $data]));
} catch (\Exception $e) {
$message = $e->getMessage();
Expand All @@ -184,6 +187,7 @@ public function isAuthenticated(): bool {
$updater->rollbackChanges($step);
}
http_response_code(500);
header('Content-Type: application/json');
echo(json_encode(['proceed' => false, 'response' => $message]));
}

Expand Down

0 comments on commit 347765d

Please sign in to comment.