Skip to content

Commit

Permalink
Add Content-Type response header for JSON responses (#90)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Gaussorgues <[email protected]>
Co-authored-by: Josh Richards <[email protected]>
  • Loading branch information
dlichtenberger and joshtrichards authored Nov 8, 2023
1 parent d2a1167 commit 44beafb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,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 @@ -1380,6 +1381,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 @@ -1395,6 +1397,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 @@ -1410,6 +1413,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 44beafb

Please sign in to comment.