Skip to content

Commit eac2c03

Browse files
fix: correctly set http response code for 503s during updates
1 parent c181ed6 commit eac2c03

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Endpoint.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,8 @@ class Endpoint {
12081208
"<?php\n" .
12091209
"\$include = include('RESTAPI/Endpoints/$nq_class_name.inc');\n" .
12101210
"if (!\$include) {\n" .
1211+
" header('Content-Type: application/json');\n" .
1212+
" http_response_code(503);\n" .
12111213
" echo '$unavailable_error_json';\n" .
12121214
" exit(503);\n" .
12131215
"}\n" .

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,10 @@ class Form {
533533
"require_once('guiconfig.inc');\n" .
534534
"\$include = include('RESTAPI/Forms/$nq_class_name.inc');\n" .
535535
"if (!\$include) {\n" .
536+
" http_response_code(503);\n" .
536537
" echo '<h1>Service Unavailable</h1>';\n" .
537538
" echo 'This resource is either not installed or is currently updating. Please try again later.';\n" .
538-
" exit(503);\n" .
539+
" exit();\n" .
539540
"}\n" .
540541
"(new $fq_class_name())->print_form();\n";
541542

@@ -549,7 +550,6 @@ class Form {
549550
if (is_file($filename)) {
550551
return true;
551552
}
552-
553553
return false;
554554
}
555555
}

0 commit comments

Comments
 (0)