When testing the error_page directive in the config file, giving a non-existant file path for a custom 404 error page causes the server to segfault if it would try to serve that error page.
Problem
Edge case.
The issue was if the custom error page would be for the 404 error specifically.
ResponseHandler would get into an infinite loop while attempting the following steps:
try to retrieve the custom error page using FileHandler::ExecuteGet
FileHandler::GetFile fails to find file and throws a NotFound exception
ResponseHandler::HandleCustomError catches this error and restarts the response-handling process to serve the 404 Not Found page
Because a custom page is set for 404 (our original issue), it would start over from step 1.
Solution
Added a check to ResponseHandler::HandleCustomError for if the newly-thrown (internal) error code is the same as which was originally requested. If so, it serves the default error page instead.
Context
When testing the
error_page
directive in the config file, giving a non-existant file path for a custom 404 error page causes the server to segfault if it would try to serve that error page.Problem
Edge case. The issue was if the custom error page would be for the 404 error specifically.
ResponseHandler
would get into an infinite loop while attempting the following steps:FileHandler::ExecuteGet
FileHandler::GetFile
fails to find file and throws a NotFound exceptionResponseHandler::HandleCustomError
catches this error and restarts the response-handling process to serve the 404 Not Found pageSolution
Added a check to
ResponseHandler::HandleCustomError
for if the newly-thrown (internal) error code is the same as which was originally requested. If so, it serves the default error page instead.