Skip to content

Commit

Permalink
fix: correctly set http response code for 503s during updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhendrickson13 committed Jan 11, 2025
1 parent c181ed6 commit eac2c03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,8 @@ class Endpoint {
"<?php\n" .
"\$include = include('RESTAPI/Endpoints/$nq_class_name.inc');\n" .
"if (!\$include) {\n" .
" header('Content-Type: application/json');\n" .
" http_response_code(503);\n" .
" echo '$unavailable_error_json';\n" .
" exit(503);\n" .
"}\n" .
Expand Down
4 changes: 2 additions & 2 deletions pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,10 @@ class Form {
"require_once('guiconfig.inc');\n" .
"\$include = include('RESTAPI/Forms/$nq_class_name.inc');\n" .
"if (!\$include) {\n" .
" http_response_code(503);\n" .
" echo '<h1>Service Unavailable</h1>';\n" .
" echo 'This resource is either not installed or is currently updating. Please try again later.';\n" .
" exit(503);\n" .
" exit();\n" .
"}\n" .
"(new $fq_class_name())->print_form();\n";

Expand All @@ -549,7 +550,6 @@ class Form {
if (is_file($filename)) {
return true;
}

return false;
}
}

0 comments on commit eac2c03

Please sign in to comment.