Changeset 1904

Show
Ignore:
Timestamp:
08/14/2007 01:25:04 PM (12 months ago)
Author:
darix
Message:

- 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


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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/src/connections.c

    r1902 r1904  
    14131413                        switch (r = http_response_prepare(srv, con)) { 
    14141414                        case HANDLER_FINISHED: 
    1415                                 if (con->http_status == 404 || 
    1416                                     con->http_status == 403) { 
    1417                                         /* 404 error-handler */ 
    1418  
    1419                                         if (con->in_error_handler == 0 && 
    1420                                             (!buffer_is_empty(con->conf.error_handler) || 
    1421                                              !buffer_is_empty(con->error_handler))) { 
    1422                                                 /* call error-handler */ 
    1423  
    1424                                                 con->error_handler_saved_status = con->http_status; 
    1425                                                 con->http_status = 0; 
    1426  
    1427                                                 if (buffer_is_empty(con->error_handler)) { 
    1428                                                         buffer_copy_string_buffer(con->request.uri, con->conf.error_handler); 
    1429                                                 } else { 
    1430                                                         buffer_copy_string_buffer(con->request.uri, con->error_handler); 
     1415                                if (con->mode == DIRECT) { 
     1416                                        if (con->http_status == 404 || 
     1417                                            con->http_status == 403) { 
     1418                                                /* 404 error-handler */ 
     1419 
     1420                                                if (con->in_error_handler == 0 && 
     1421                                                    (!buffer_is_empty(con->conf.error_handler) || 
     1422                                                     !buffer_is_empty(con->error_handler))) { 
     1423                                                        /* call error-handler */ 
     1424 
     1425                                                        con->error_handler_saved_status = con->http_status; 
     1426                                                        con->http_status = 0; 
     1427 
     1428                                                        if (buffer_is_empty(con->error_handler)) { 
     1429                                                                buffer_copy_string_buffer(con->request.uri, con->conf.error_handler); 
     1430                                                        } else { 
     1431                                                                buffer_copy_string_buffer(con->request.uri, con->error_handler); 
     1432                                                        } 
     1433                                                        buffer_reset(con->physical.path); 
     1434 
     1435                                                        con->in_error_handler = 1; 
     1436 
     1437                                                        connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST); 
     1438 
     1439                                                        done = -1; 
     1440                                                        break; 
     1441                                                } else if (con->in_error_handler) { 
     1442                                                        /* error-handler is a 404 */ 
     1443 
     1444                                                        con->http_status = con->error_handler_saved_status; 
    14311445                                                } 
    1432                                                 buffer_reset(con->physical.path); 
    1433  
    1434                                                 con->in_error_handler = 1; 
    1435  
    1436                                                 connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST); 
    1437  
    1438                                                 done = -1; 
    1439                                                 break; 
    14401446                                        } else if (con->in_error_handler) { 
    1441                                                 /* error-handler is a 404 */ 
    1442  
    1443                                                 con->http_status = con->error_handler_saved_status; 
     1447                                                /* error-handler is back and has generated content */ 
     1448                                                /* if Status: was set, take it otherwise use 200 */ 
    14441449                                        } 
    1445                                 } else if (con->in_error_handler) { 
    1446                                         /* error-handler is back and has generated content */ 
    1447                                         /* if Status: was set, take it otherwise use 200 */ 
    1448                                         /* the default should be 200 for now. 
    1449                                            but this breaks 948 again. solution 
    1450                                            pending 
    1451                                         if (con->http_status == 0) { 
    1452                                                 con->http_status = con->error_handler_saved_status; 
    1453                                         } 
    1454                                         */ 
    14551450                                } 
    1456  
    14571451                                if (con->http_status == 0) con->http_status = 200; 
    14581452