From baec632cb7869db2c5a326e2da4ffdb693df5f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20R=C3=BCckert?= Date: Tue, 14 Aug 2007 13:25:04 +0000 Subject: [PATCH] - finally! the fix for 948. only run into the 404 handler if we are in direct connection mode. that way we cant run into the 404 handler if a fastcgi app returned a 404. This is a small backwards incompatible change as now the *cgi app has to generate the content for the 404 itself instead of falling back into the 404-handler. There is still a problem with subrequest which go back to the same module (fastcgi app triggers subrequest which hits the fastcgi module again) but that would require bigger changes to the plugin api. ATM each plugin deinitialize its data after it handled the request. So the module isnt initialized for the connection anymore and the subrequest directly jumps out of the handler. git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1904 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/connections.c | 64 +++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/src/connections.c b/src/connections.c index 7f9076d8..23ce5883 100644 --- a/src/connections.c +++ b/src/connections.c @@ -1412,48 +1412,42 @@ int connection_state_machine(server *srv, connection *con) { switch (r = http_response_prepare(srv, con)) { case HANDLER_FINISHED: - if (con->http_status == 404 || - con->http_status == 403) { - /* 404 error-handler */ + if (con->mode == DIRECT) { + if (con->http_status == 404 || + con->http_status == 403) { + /* 404 error-handler */ - if (con->in_error_handler == 0 && - (!buffer_is_empty(con->conf.error_handler) || - !buffer_is_empty(con->error_handler))) { - /* call error-handler */ + if (con->in_error_handler == 0 && + (!buffer_is_empty(con->conf.error_handler) || + !buffer_is_empty(con->error_handler))) { + /* call error-handler */ - con->error_handler_saved_status = con->http_status; - con->http_status = 0; + con->error_handler_saved_status = con->http_status; + con->http_status = 0; - if (buffer_is_empty(con->error_handler)) { - buffer_copy_string_buffer(con->request.uri, con->conf.error_handler); - } else { - buffer_copy_string_buffer(con->request.uri, con->error_handler); + if (buffer_is_empty(con->error_handler)) { + buffer_copy_string_buffer(con->request.uri, con->conf.error_handler); + } else { + buffer_copy_string_buffer(con->request.uri, con->error_handler); + } + buffer_reset(con->physical.path); + + con->in_error_handler = 1; + + connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST); + + done = -1; + break; + } else if (con->in_error_handler) { + /* error-handler is a 404 */ + + con->http_status = con->error_handler_saved_status; } - buffer_reset(con->physical.path); - - con->in_error_handler = 1; - - connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST); - - done = -1; - break; } else if (con->in_error_handler) { - /* error-handler is a 404 */ - - con->http_status = con->error_handler_saved_status; + /* error-handler is back and has generated content */ + /* if Status: was set, take it otherwise use 200 */ } - } else if (con->in_error_handler) { - /* error-handler is back and has generated content */ - /* if Status: was set, take it otherwise use 200 */ - /* the default should be 200 for now. - but this breaks 948 again. solution - pending - if (con->http_status == 0) { - con->http_status = con->error_handler_saved_status; - } - */ } - if (con->http_status == 0) con->http_status = 200; /* we have something to send, go on */