summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-01-26 12:09:43 +0000
committerAndrew Clayton <a.clayton@nginx.com>2023-01-27 14:46:59 +0000
commitbebc03c729df1d7efc81a5af8b8dac40b333d408 (patch)
tree6de72d17c785452f048327844c897cc2522ae2cf /test
parentfafdb7a57ad976e048147fe23079dca9c602e88a (diff)
downloadunit-bebc03c729df1d7efc81a5af8b8dac40b333d408.tar.gz
unit-bebc03c729df1d7efc81a5af8b8dac40b333d408.tar.bz2
PHP: Implement better error handling.
Previously the PHP module would produce one of four status codes 200 OK 301 Moved Permanently 500 Internal Server Error 503 Service Unavailable 200 for successful requests, 301 for cases where the url was a directory without a trailing '/', 500 for bad PHP or non-existing PHP file and 503 for all other errors. With this commit we now handle missing files and directories, returning 404 Not Found and files and directories that don't allow access, returning 403 Forbidden. We do these checks in two places, when we check if we should do a directory redirect (bar -> bar/) and in the nxt_php_execute() function. One snag with the latter is that the php_execute_script() function only returns success/failure (no reason). However while it took a zend_file_handle structure with the filename of the script to run, we can instead pass through an already opened file-pointer (FILE *) via that structure. So we can try opening the script ourselves and do the required checks before calling php_execute_script(). We also make use of the zend_stream_init_fp() function that initialises the zend_file_handle structure if it's available otherwise we use our own version. This is good because the zend_file_handle structure has changed over time and the zend_stream_init_fp() function should change with it. Closes: <https://github.com/nginx/unit/issues/767> Reviewed-by: Alejandro Colomar <alx@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions