the patch attached to #119 was right. If we

have content on a HEAD request, take it as the 
Content-Length and discard the content (as it is
a HEAD request)


git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1385 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.13
Jan Kneschke 2006-10-07 17:47:49 +00:00
parent 9a49269981
commit d6bfa8aaa8
1 changed files with 10 additions and 4 deletions

View File

@ -522,11 +522,17 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
/* we have all the content and chunked encoding is not used, set a content-length */
if ((!(con->parsed_response & HTTP_CONTENT_LENGTH)) &&
(con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0 &&
con->request.http_method != HTTP_METHOD_HEAD) { /* don't force a Content-Length if we had a HEAD request */
buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue));
(con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0) {
off_t qlen = chunkqueue_length(con->write_queue);
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf));
/* if we have no content for a GET/PORT request, send Content-Length: 0
* if it is a HEAD request, don't generate a Content-Length as
* the backend might have already cut it off */
if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) {
buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue));
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf));
}
}
} else {
/* disable keep-alive if size-info for the body is missing */