Changeset 1924

Show
Ignore:
Timestamp:
08/17/2007 03:37:45 PM (14 months ago)
Author:
jan
Message:

fixed duplicate code which handles the "disable keep-alive" for dynamic
content (fixes #1166)

Files:
1 modified

Legend:

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

    r1904 r1924  
    535535                } 
    536536        } else { 
    537                 /* disable keep-alive if size-info for the body is missing */ 
    538                 if ((con->parsed_response & HTTP_CONTENT_LENGTH) && 
     537                /** 
     538                 * the file isn't finished yet, but we have all headers 
     539                 * 
     540                 * to get keep-alive we either need: 
     541                 * - Content-Length: ... (HTTP/1.0 and HTTP/1.0) or 
     542                 * - Transfer-Encoding: chunked (HTTP/1.1) 
     543                 */ 
     544 
     545                if (((con->parsed_response & HTTP_CONTENT_LENGTH) == 0) && 
    539546                    ((con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0)) { 
    540547                        con->keep_alive = 0; 
    541548                } 
    542549 
    543                 if (0 == (con->parsed_response & HTTP_CONNECTION)) { 
    544                         /* (f)cgi did'nt send Connection: header 
    545                          * 
    546                          * shall we ? 
    547                          */ 
    548                         if (((con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0) && 
    549                             (con->parsed_response & HTTP_CONTENT_LENGTH) == 0) { 
    550                                 /* without content_length, no keep-alive */ 
    551  
    552                                 con->keep_alive = 0; 
    553                         } 
    554                 } else { 
     550                /** 
     551                 * if the backend sent a Connection: close, follow the wish 
     552                 * 
     553                 * NOTE: if the backend sent Connection: Keep-Alive, but no Content-Length, we 
     554                 * will close the connection. That's fine. We can always decide the close  
     555                 * the connection 
     556                 * 
     557                 * FIXME: to be nice we should remove the Connection: ...  
     558                 */ 
     559                if (con->parsed_response & HTTP_CONNECTION) { 
    555560                        /* a subrequest disable keep-alive although the client wanted it */ 
    556561                        if (con->keep_alive && !con->response.keep_alive) { 
    557562                                con->keep_alive = 0; 
    558  
    559                                 /* FIXME: we have to drop the Connection: Header from the subrequest */ 
    560563                        } 
    561564                }