Changeset 2098

Show
Ignore:
Timestamp:
02/27/2008 12:15:38 PM (6 months ago)
Author:
stbuehler
Message:

Fix Content-Length header if response body gets removed in connections.c (#1412, part 2)

  • do not touch if it is a HEAD request (but set file_finished)
  • body gets removed for req method OPTION and some status codes
Location:
branches/lighttpd-1.4.x
Files:
2 modified

Legend:

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

    r2097 r2098  
    4141  * fixed mod-proxy.t to run with a builddir outside of the src dir 
    4242  * do not suppress content on "307 Temporary Redirect" (#1412) 
     43  * fixed Content-Length header if response body gets removed in connections.c (#1412, part 2) 
    4344 
    4445- 1.4.18 - 2007-09-09 
  • branches/lighttpd-1.4.x/src/connections.c

    r2097 r2098  
    399399                                response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("OPTIONS, GET, HEAD, POST")); 
    400400 
     401                                con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; 
     402                                con->parsed_response &= ~HTTP_CONTENT_LENGTH; 
     403 
    401404                                con->http_status = 200; 
    402405                                con->file_finished = 1; 
     
    513516                /* disable chunked encoding again as we have no body */ 
    514517                con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; 
     518                con->parsed_response &= ~HTTP_CONTENT_LENGTH; 
    515519                chunkqueue_reset(con->write_queue); 
    516520 
     
    518522                break; 
    519523        } 
    520  
    521524 
    522525        if (con->file_finished) { 
     
    538541                            con->http_status == 204 || 
    539542                            con->http_status == 304) { 
     543                                data_string *ds; 
    540544                                /* no Content-Body, no Content-Length */ 
     545                                if (NULL != (ds = (data_string*) array_get_element(con->response.headers, "Content-Length"))) { 
     546                                        buffer_reset(ds->value); // Headers with empty values are ignored for output 
     547                                } 
    541548                        } else if (qlen >= 0) { 
    542549                                /* qlen = 0 is important for Redirects (301, ...) as they MAY have 
     
    584591                 * without the content 
    585592                 */ 
     593                con->file_finished = 1; 
     594 
    586595                chunkqueue_reset(con->write_queue); 
    587596                con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;