diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-11-24 20:44:23 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-12-05 18:40:25 +0100 |
commit | 2618d67fe5eda1e86f90de2fcde90c048fbcd50b (patch) | |
tree | d73035fad1149a099c92aa88db92cac3d41b5491 /source4/web_server | |
parent | ad252fb2f5b403001a283aff58773b8b429be145 (diff) | |
download | samba-2618d67fe5eda1e86f90de2fcde90c048fbcd50b.tar.gz samba-2618d67fe5eda1e86f90de2fcde90c048fbcd50b.tar.bz2 samba-2618d67fe5eda1e86f90de2fcde90c048fbcd50b.zip |
wsgi: Serve '500 Internal Server Error' page when errors occur.
Autobuild-User(master): Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date(master): Wed Dec 5 18:40:25 CET 2012 on sn-devel-104
Diffstat (limited to 'source4/web_server')
-rw-r--r-- | source4/web_server/wsgi.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c index 615726ad7a..17ad65afe4 100644 --- a/source4/web_server/wsgi.c +++ b/source4/web_server/wsgi.c @@ -410,6 +410,22 @@ error: return NULL; } +static void wsgi_serve_500(struct websrv_context *web) +{ + struct http_header *headers = NULL; + const char *contents[] = { + "An internal server error occurred while handling this request. ", + "Please refer to the server logs for more details. ", + NULL + }; + int i; + + websrv_output_headers(web, "500 Internal Server Error", headers); + for (i = 0; contents[i]; i++) { + websrv_output(web, contents[i], strlen(contents[i])); + } +} + static void wsgi_process_http_input(struct web_server_data *wdata, struct websrv_context *web) { @@ -453,6 +469,7 @@ static void wsgi_process_http_input(struct web_server_data *wdata, if (py_environ == NULL) { DEBUG_Print_PyError(0, "Unable to create WSGI environment object"); + wsgi_serve_500(web); return; } @@ -461,6 +478,7 @@ static void wsgi_process_http_input(struct web_server_data *wdata, if (result == NULL) { DEBUG_Print_PyError(0, "error while handling request"); + wsgi_serve_500(web); return; } @@ -469,6 +487,7 @@ static void wsgi_process_http_input(struct web_server_data *wdata, if (iter == NULL) { DEBUG_Print_PyError(0, "application did not return iterable"); + wsgi_serve_500(web); return; } |