Ticket #119: lighttpd-#119-v1.patch

File lighttpd-#119-v1.patch, 0.9 kB (added by bdash, 3 years ago)

Only overwrite the Content-Length header for a non-HEAD request or if we have non-zero-length response body

  • src/connections.c

     
    483483                 
    484484                if ((!(con->parsed_response & HTTP_CONTENT_LENGTH)) &&  
    485485                    (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0) { 
    486                         buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue)); 
    487                  
    488                         response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf)); 
     486                  if (con->request.http_method != HTTP_METHOD_HEAD || chunkqueue_length(con->write_queue) > 0) { 
     487                    buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue)); 
     488                    response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf)); 
     489                  } 
    489490                } 
    490491        } else { 
    491492                /* disable keep-alive if size-info for the body is missing */