Changeset 2154

Show
Ignore:
Timestamp:
04/23/2008 07:10:42 PM (3 months ago)
Author:
stbuehler
Message:

Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lighttpd-1.4.x/NEWS

    r2153 r2154  
    2020  * Overwrite Content-Type header in mod_dirlisting instead of inserting (#1614), patch by Henrik Holst 
    2121  * Handle EINTR in mod_cgi during write() (#1640) 
     22  * Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639) 
    2223 
    2324- 1.4.19 - 2008-03-10 
  • branches/lighttpd-1.4.x/src/connections.c

    r2151 r2154  
    429429 
    430430        switch(con->http_status) { 
    431         case 400: /* class: header + custom body */ 
    432         case 401: 
    433         case 403: 
    434         case 404: 
    435         case 408: 
    436         case 409: 
    437         case 411: 
    438         case 416: 
    439         case 423: 
    440         case 500: 
    441         case 501: 
    442         case 503: 
    443         case 505: 
     431        case 204: /* class: header only */ 
     432        case 205: 
     433        case 304: 
     434                /* disable chunked encoding again as we have no body */ 
     435                con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; 
     436                con->parsed_response &= ~HTTP_CONTENT_LENGTH; 
     437                chunkqueue_reset(con->write_queue); 
     438 
     439                con->file_finished = 1; 
     440                break; 
     441        default: /* class: header + body */ 
    444442                if (con->mode != DIRECT) break; 
     443 
     444                /* only custom body for 4xx and 5xx */ 
     445                if (con->http_status < 400 || con->http_status >= 600) break; 
    445446 
    446447                con->file_finished = 0; 
     
    453454 
    454455                        buffer_copy_string_buffer(con->physical.path, con->conf.errorfile_prefix); 
    455                         buffer_append_string(con->physical.path, get_http_status_body_name(con->http_status)); 
     456                        buffer_append_long(con->physical.path, con->http_status); 
     457                        buffer_append_string_len(con->physical.path, CONST_STR_LEN(".html")); 
    456458 
    457459                        if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) { 
     
    499501                        response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); 
    500502                } 
    501                 /* fall through */ 
    502         case 207: 
    503         case 200: /* class: header + body */ 
    504         case 201: 
    505         case 300: 
    506         case 301: 
    507         case 302: 
    508         case 303: 
    509         case 307: 
    510                 break; 
    511  
    512         case 206: /* write_queue is already prepared */ 
    513                 break; 
    514         case 204: 
    515         case 205: /* class: header only */ 
    516         case 304: 
    517         default: 
    518                 /* disable chunked encoding again as we have no body */ 
    519                 con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; 
    520                 con->parsed_response &= ~HTTP_CONTENT_LENGTH; 
    521                 chunkqueue_reset(con->write_queue); 
    522  
    523                 con->file_finished = 1; 
    524503                break; 
    525504        } 
  • branches/lighttpd-1.4.x/tests/request.t

    r2027 r2154  
    102102EOF 
    103103 ); 
    104 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417, '-HTTP-Content' => ''} ]; 
     104$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417 } ]; 
    105105ok($tf->handle_http($t) == 0, 'Continue, Expect'); 
    106106