Skip to content

Commit c6f71fd

Browse files
Altahrimcome-nc
authored andcommitted
Add Content-Type response header for JSON responses
Initial work in #90 Signed-off-by: Benjamin Gaussorgues <[email protected]>
1 parent e73aa39 commit c6f71fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.web.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function isAuthenticated(): bool {
5454
if (isset($_POST['step'])) {
5555
// mark step as failed
5656
http_response_code(500);
57+
header('Content-Type: application/json');
5758
echo(json_encode(['proceed' => false, 'response' => $e->getMessage()]));
5859
die();
5960
}
@@ -140,6 +141,7 @@ public function isAuthenticated(): bool {
140141
break;
141142
}
142143
$updater->endStep($step);
144+
header('Content-Type: application/json');
143145
echo(json_encode(['proceed' => true]));
144146
} catch (UpdateException $e) {
145147
$data = $e->getData();
@@ -155,6 +157,7 @@ public function isAuthenticated(): bool {
155157
$updater->rollbackChanges($step);
156158
}
157159
http_response_code(500);
160+
header('Content-Type: application/json');
158161
echo(json_encode(['proceed' => false, 'response' => $data]));
159162
} catch (\Exception $e) {
160163
$message = $e->getMessage();
@@ -170,6 +173,7 @@ public function isAuthenticated(): bool {
170173
$updater->rollbackChanges($step);
171174
}
172175
http_response_code(500);
176+
header('Content-Type: application/json');
173177
echo(json_encode(['proceed' => false, 'response' => $message]));
174178
}
175179

0 commit comments

Comments
 (0)