summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2018-10-14 17:29:10 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2018-10-14 17:29:10 -0400
commit98f5cc6f0d18e65d7b423f2f2a5d9383a4aa893f (patch)
tree9f3fae906179633eb381b90d7109c3373adddffc
parentbc25684f0c1b27de2cbee7a7df82f249611547c4 (diff)
downloadlighttpd-git-98f5cc6f0d18e65d7b423f2f2a5d9383a4aa893f.tar.gz
[core] permit server.error_handler to static file
This use is not recommended since it means that the response body will not contain the precise error code. x-ref: "What is the proper syntax for server.error-handler in 1.4.45" https://redmine.lighttpd.net/boards/2/topics/8320
-rw-r--r--src/connections.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/connections.c b/src/connections.c
index 4ff9184d..b5b31ce8 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -302,6 +302,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
if (con->http_status < 400 || con->http_status >= 600) break;
if (con->mode != DIRECT && (!con->conf.error_intercept || con->error_handler_saved_status)) break;
+ if (con->mode == DIRECT && con->error_handler_saved_status >= 65535) break;
con->file_finished = 0;
@@ -1174,11 +1175,13 @@ int connection_state_machine(server *srv, connection *con) {
/* response headers received from backend; fall through to start response */
/* fall through */
case HANDLER_FINISHED:
+ if (con->http_status == 0) con->http_status = 200;
if (con->error_handler_saved_status > 0) {
con->request.http_method = con->error_handler_saved_method;
}
if (con->mode == DIRECT || con->conf.error_intercept) {
if (con->error_handler_saved_status) {
+ const int subreq_status = con->http_status;
if (con->error_handler_saved_status > 0) {
con->http_status = con->error_handler_saved_status;
} else if (con->http_status == 404 || con->http_status == 403) {
@@ -1188,6 +1191,11 @@ int connection_state_machine(server *srv, connection *con) {
/* error-handler-404 is back and has generated content */
/* if Status: was set, take it otherwise use 200 */
}
+ if (200 <= subreq_status && subreq_status <= 299) {
+ /*(flag value to indicate that error handler succeeded)
+ *(for (con->mode == DIRECT))*/
+ con->error_handler_saved_status = 65535; /* >= 1000 */
+ }
} else if (con->http_status >= 400) {
buffer *error_handler = NULL;
if (!buffer_string_is_empty(con->conf.error_handler)) {
@@ -1239,7 +1247,6 @@ int connection_state_machine(server *srv, connection *con) {
}
}
}
- if (con->http_status == 0) con->http_status = 200;
/* we have something to send, go on */
connection_set_state(srv, con, CON_STATE_RESPONSE_START);