Browse Source

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


git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2098 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.19
Stefan Bühler 14 years ago
parent
commit
d1bb91108d
  1. 1
      NEWS
  2. 11
      src/connections.c

1
NEWS

@ -40,6 +40,7 @@ NEWS
* check for symlinks after successful pathinfo matching (#1574)
* fixed mod-proxy.t to run with a builddir outside of the src dir
* do not suppress content on "307 Temporary Redirect" (#1412)
* fixed Content-Length header if response body gets removed in connections.c (#1412, part 2)
- 1.4.18 - 2007-09-09

11
src/connections.c

@ -398,6 +398,9 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
con->uri.path->ptr[0] != '*') {
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("OPTIONS, GET, HEAD, POST"));
con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
con->parsed_response &= ~HTTP_CONTENT_LENGTH;
con->http_status = 200;
con->file_finished = 1;
@ -512,13 +515,13 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
default:
/* disable chunked encoding again as we have no body */
con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
con->parsed_response &= ~HTTP_CONTENT_LENGTH;
chunkqueue_reset(con->write_queue);
con->file_finished = 1;
break;
}
if (con->file_finished) {
/* we have all the content and chunked encoding is not used, set a content-length */
@ -537,7 +540,11 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
if ((con->http_status >= 100 && con->http_status < 200) ||
con->http_status == 204 ||
con->http_status == 304) {
data_string *ds;
/* no Content-Body, no Content-Length */
if (NULL != (ds = (data_string*) array_get_element(con->response.headers, "Content-Length"))) {
buffer_reset(ds->value); // Headers with empty values are ignored for output
}
} else if (qlen >= 0) {
/* qlen = 0 is important for Redirects (301, ...) as they MAY have
* a content. Browsers are waiting for a Content otherwise
@ -583,6 +590,8 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
* a HEAD request has the same as a GET
* without the content
*/
con->file_finished = 1;
chunkqueue_reset(con->write_queue);
con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
}

Loading…
Cancel
Save