Browse Source

Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2154 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.20
Stefan Bühler 14 years ago
parent
commit
ac92ea3616
  1. 1
      NEWS
  2. 53
      src/connections.c
  3. 2
      tests/request.t

1
NEWS

@ -19,6 +19,7 @@ NEWS
* Fix mod_fastcgi prefix matching: match the prefix always against url, not the absolute filepath (regardless of check-local)
* Overwrite Content-Type header in mod_dirlisting instead of inserting (#1614), patch by Henrik Holst
* Handle EINTR in mod_cgi during write() (#1640)
* Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639)
- 1.4.19 - 2008-03-10

53
src/connections.c

@ -428,21 +428,22 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
}
switch(con->http_status) {
case 400: /* class: header + custom body */
case 401:
case 403:
case 404:
case 408:
case 409:
case 411:
case 416:
case 423:
case 500:
case 501:
case 503:
case 505:
case 204: /* class: header only */
case 205:
case 304:
/* 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;
default: /* class: header + body */
if (con->mode != DIRECT) break;
/* only custom body for 4xx and 5xx */
if (con->http_status < 400 || con->http_status >= 600) break;
con->file_finished = 0;
buffer_reset(con->physical.path);
@ -452,7 +453,8 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
stat_cache_entry *sce = NULL;
buffer_copy_string_buffer(con->physical.path, con->conf.errorfile_prefix);
buffer_append_string(con->physical.path, get_http_status_body_name(con->http_status));
buffer_append_long(con->physical.path, con->http_status);
buffer_append_string_len(con->physical.path, CONST_STR_LEN(".html"));
if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) {
con->file_finished = 1;
@ -498,29 +500,6 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
}
/* fall through */
case 207:
case 200: /* class: header + body */
case 201:
case 300:
case 301:
case 302:
case 303:
case 307:
break;
case 206: /* write_queue is already prepared */
break;
case 204:
case 205: /* class: header only */
case 304:
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;
}

2
tests/request.t

@ -101,7 +101,7 @@ Connection: close
Expect: 100-continue
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417, '-HTTP-Content' => ''} ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417 } ];
ok($tf->handle_http($t) == 0, 'Continue, Expect');
## ranges

Loading…
Cancel
Save