1 Index: src/connections.c
2 ===================================================================
3 --- src/connections.c (.../tags/lighttpd-1.4.16) (revision 1922)
4 +++ src/connections.c (.../branches/lighttpd-1.4.x) (revision 1922)
5 @@ -1412,42 +1412,42 @@
7 switch (r = http_response_prepare(srv, con)) {
9 - if (con->http_status == 404 ||
10 - con->http_status == 403) {
11 - /* 404 error-handler */
12 + if (con->mode == DIRECT) {
13 + if (con->http_status == 404 ||
14 + con->http_status == 403) {
15 + /* 404 error-handler */
17 - if (con->in_error_handler == 0 &&
18 - (!buffer_is_empty(con->conf.error_handler) ||
19 - !buffer_is_empty(con->error_handler))) {
20 - /* call error-handler */
21 + if (con->in_error_handler == 0 &&
22 + (!buffer_is_empty(con->conf.error_handler) ||
23 + !buffer_is_empty(con->error_handler))) {
24 + /* call error-handler */
26 - con->error_handler_saved_status = con->http_status;
27 - con->http_status = 0;
28 + con->error_handler_saved_status = con->http_status;
29 + con->http_status = 0;
31 - if (buffer_is_empty(con->error_handler)) {
32 - buffer_copy_string_buffer(con->request.uri, con->conf.error_handler);
34 - buffer_copy_string_buffer(con->request.uri, con->error_handler);
36 - buffer_reset(con->physical.path);
37 + if (buffer_is_empty(con->error_handler)) {
38 + buffer_copy_string_buffer(con->request.uri, con->conf.error_handler);
40 + buffer_copy_string_buffer(con->request.uri, con->error_handler);
42 + buffer_reset(con->physical.path);
44 - con->in_error_handler = 1;
45 + con->in_error_handler = 1;
47 - connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST);
48 + connection_set_state(srv, con, CON_STATE_HANDLE_REQUEST);
54 + } else if (con->in_error_handler) {
55 + /* error-handler is a 404 */
57 + con->http_status = con->error_handler_saved_status;
59 } else if (con->in_error_handler) {
60 - /* error-handler is a 404 */
62 - con->http_status = con->error_handler_saved_status;
63 + /* error-handler is back and has generated content */
64 + /* if Status: was set, take it otherwise use 200 */
66 - } else if (con->in_error_handler) {
67 - /* error-handler is back and has generated content */
68 - /* if Status: was set, take it otherwise use 200 */
69 - con->http_status = con->error_handler_saved_status;
72 if (con->http_status == 0) con->http_status = 200;
74 /* we have something to send, go on */
75 Index: src/mod_staticfile.c
76 ===================================================================
77 --- src/mod_staticfile.c (.../tags/lighttpd-1.4.16) (revision 1922)
78 +++ src/mod_staticfile.c (.../branches/lighttpd-1.4.x) (revision 1922)
81 http_chunk_append_file(srv, con, con->physical.path, 0, sce->st.st_size);
83 + con->http_status = 200;
84 con->file_finished = 1;
86 return HANDLER_FINISHED;
88 ===================================================================
89 --- src/etag.c (.../tags/lighttpd-1.4.16) (revision 1922)
90 +++ src/etag.c (.../branches/lighttpd-1.4.x) (revision 1922)
100 int etag_mutate(buffer *mut, buffer *etag) {
105 for (h=0, i=0; i < etag->used; ++i) h = (h<<5)^(h>>27)^(etag->ptr[i]);
107 Index: src/mod_mysql_vhost.c
108 ===================================================================
109 --- src/mod_mysql_vhost.c (.../tags/lighttpd-1.4.16) (revision 1922)
110 +++ src/mod_mysql_vhost.c (.../branches/lighttpd-1.4.x) (revision 1922)
113 return HANDLER_ERROR;
116 + /* in mysql versions above 5.0.3 the reconnect flag is off by default */
117 + my_bool reconnect = 1;
118 + mysql_options(s->mysql, MYSQL_OPT_RECONNECT, &reconnect);
120 #define FOO(x) (s->x->used ? s->x->ptr : NULL)
122 if (!mysql_real_connect(s->mysql, FOO(hostname), FOO(myuser), FOO(mypass),
123 Index: src/mod_compress.c
124 ===================================================================
125 --- src/mod_compress.c (.../tags/lighttpd-1.4.16) (revision 1922)
126 +++ src/mod_compress.c (.../branches/lighttpd-1.4.x) (revision 1922)
128 /* don't compress files that are too large as we need to much time to handle them */
129 if (max_fsize && (sce->st.st_size >> 10) > max_fsize) return HANDLER_GO_ON;
131 + /* don't try to compress files less than 128 bytes
133 + * - extra overhead for compression
134 + * - mmap() fails for st_size = 0 :)
136 + if (sce->st.st_size < 128) return HANDLER_GO_ON;
138 /* check if mimetype is in compress-config */
139 for (m = 0; m < p->conf.compress->used; m++) {
140 data_string *compress_ds = (data_string *)p->conf.compress->data[m];
141 Index: src/mod_dirlisting.c
142 ===================================================================
143 --- src/mod_dirlisting.c (.../tags/lighttpd-1.4.16) (revision 1922)
144 +++ src/mod_dirlisting.c (.../branches/lighttpd-1.4.x) (revision 1922)
147 buffer *external_css;
149 + buffer *set_footer;
154 excludes_buffer_free(s->excludes);
155 buffer_free(s->external_css);
156 buffer_free(s->encoding);
157 + buffer_free(s->set_footer);
162 #define CONFIG_SHOW_HEADER "dir-listing.show-header"
163 #define CONFIG_HIDE_HEADER_FILE "dir-listing.hide-header-file"
164 #define CONFIG_DIR_LISTING "server.dir-listing"
165 +#define CONFIG_SET_FOOTER "dir-listing.set-footer"
168 SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
169 plugin_data *p = p_d;
172 { CONFIG_SHOW_HEADER, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
173 { CONFIG_HIDE_HEADER_FILE, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
174 { CONFIG_DIR_LISTING, NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
175 + { CONFIG_SET_FOOTER, NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
177 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
181 s->hide_header_file = 0;
182 s->encoding = buffer_init();
183 + s->set_footer = buffer_init();
185 cv[0].destination = s->excludes;
186 cv[1].destination = &(s->dir_listing);
188 cv[7].destination = &(s->show_header);
189 cv[8].destination = &(s->hide_header_file);
190 cv[9].destination = &(s->dir_listing); /* old name */
191 + cv[10].destination = s->set_footer;
193 p->config_storage[i] = s;
194 ca = ((data_config *)srv->config_context->data[i])->value;
197 PATCH(hide_header_file);
201 /* skip the first, the global context */
202 for (i = 1; i < srv->config_context->used; i++) {
205 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_HEADER_FILE))) {
206 PATCH(hide_header_file);
207 + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SET_FOOTER))) {
209 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXCLUDE))) {
213 "h2 {margin-bottom: 12px;}\n"
214 "table {margin-left: 12px;}\n"
216 - " font-family: \"Courier New\", Courier, monospace;"
217 - " font-size: 10pt;"
218 + " font: 90% monospace;"
223 " padding-bottom: 14px;"
226 - " font-family: \"Courier New\", Courier, monospace;"
227 - " font-size: 10pt;"
228 + " font: 90% monospace;"
233 "<div class=\"foot\">"
236 - if (buffer_is_empty(con->conf.server_tag)) {
237 + if (p->conf.set_footer->used > 1) {
238 + buffer_append_string_buffer(out, p->conf.set_footer);
239 + } else if (buffer_is_empty(con->conf.server_tag)) {
240 BUFFER_APPEND_STRING_CONST(out, PACKAGE_NAME "/" PACKAGE_VERSION);
242 buffer_append_string_buffer(out, con->conf.server_tag);
243 Index: tests/404-handler.conf
244 ===================================================================
245 --- tests/404-handler.conf (.../tags/lighttpd-1.4.16) (revision 0)
246 +++ tests/404-handler.conf (.../branches/lighttpd-1.4.x) (revision 1922)
248 +debug.log-request-handling = "enable"
249 +debug.log-response-header = "enable"
250 +debug.log-request-header = "enable"
252 +server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
253 +server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
255 +## bind to port (default: 80)
258 +## bind to localhost (default: all interfaces)
259 +server.bind = "localhost"
260 +server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
261 +server.name = "www.example.org"
262 +server.tag = "Apache 1.3.29"
270 +######################## MODULE CONFIG ############################
273 +accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"
275 +mimetype.assign = ( ".html" => "text/html" )
277 +cgi.assign = (".pl" => "/usr/bin/perl" )
279 +# fastcgi.server += ( "/404.pl" =>
280 +# ( "404-handler" =>
282 +# "socket" => env.SRCDIR + "/tmp/pl-404-fastcgi-1.socket",
283 +# "bin-path" => server.document-root + "/404.pl",
285 +# "check-local" => "disable",
286 +# "broken-scriptfilename" => "enable",
291 +$HTTP["url"] =~ "^/static/" {
292 + server.error-handler-404 = "/404.html"
294 +else $HTTP["url"] =~ "." {
295 + server.error-handler-404 = "/404.pl"
297 Index: tests/mod-cgi.t
298 ===================================================================
299 --- tests/mod-cgi.t (.../tags/lighttpd-1.4.16) (revision 1922)
300 +++ tests/mod-cgi.t (.../branches/lighttpd-1.4.x) (revision 1922)
305 -use Test::More tests => 15;
306 +use Test::More tests => 16;
309 my $tf = LightyTest->new();
312 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '+Content-Length' => '' } ];
313 ok($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
314 +# broken header crash
315 +$t->{REQUEST} = ( <<EOF
316 +GET /crlfcrash.pl HTTP/1.0
319 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 500 } ];
320 +ok($tf->handle_http($t) == 0, 'broken header via perl cgi');
322 ok($tf->stop_proc == 0, "Stopping lighttpd");
324 Index: tests/docroot/www/crlfcrash.pl
325 ===================================================================
326 --- tests/docroot/www/crlfcrash.pl (.../tags/lighttpd-1.4.16) (revision 0)
327 +++ tests/docroot/www/crlfcrash.pl (.../branches/lighttpd-1.4.x) (revision 1922)
331 +print "Location: http://www.example.org/\r\n\n\n";
333 Index: tests/docroot/www/404.pl
334 ===================================================================
335 --- tests/docroot/www/404.pl (.../tags/lighttpd-1.4.16) (revision 0)
336 +++ tests/docroot/www/404.pl (.../branches/lighttpd-1.4.x) (revision 1922)
339 +use CGI qw/:standard/;
341 +my $request_uri = $ENV{'REQUEST_URI'};
342 +print (STDERR "REQUEST_URI: $request_uri\n");
344 +if ($request_uri =~ m/^\/dynamic\/200\// ) {
345 + print header ( -status => 200,
346 + -type => 'text/plain' );
347 + print ("found here\n");
349 +elsif ($request_uri =~ m|^/dynamic/302/| ) {
350 + print header( -status=>302,
351 + -location => 'http://www.example.org/');
353 +elsif ($request_uri =~ m/^\/dynamic\/404\// ) {
354 + print header ( -status => 404
355 + -type => 'text/plain' );
356 + print ("Not found here\n");
358 +elsif ($request_uri =~ m/^\/send404\.pl/ ) {
359 + print header ( -status => 404
360 + -type => 'text/plain' );
361 + print ("Not found here (send404)\n");
363 +elsif ($request_uri =~ m/^\/dynamic\/nostatus\// ) {
364 + print ("found here\n");
367 + print header ( -status => 500,
368 + -type => 'text/plain');
372 Property changes on: tests/docroot/www/404.pl
373 ___________________________________________________________________
377 Index: tests/docroot/www/send404.pl
378 ===================================================================
379 --- tests/docroot/www/send404.pl (.../tags/lighttpd-1.4.16) (revision 0)
380 +++ tests/docroot/www/send404.pl (.../branches/lighttpd-1.4.x) (revision 1922)
383 +use CGI qw/:standard/;
384 +print header ( -status => 404
385 + -type => 'text/plain' );
386 +print ("send404\n");
388 Property changes on: tests/docroot/www/send404.pl
389 ___________________________________________________________________
393 Index: tests/docroot/www/404.html
394 ===================================================================
395 --- tests/docroot/www/404.html (.../tags/lighttpd-1.4.16) (revision 0)
396 +++ tests/docroot/www/404.html (.../branches/lighttpd-1.4.x) (revision 1922)
399 Index: tests/docroot/www/404.fcgi
400 ===================================================================
401 --- tests/docroot/www/404.fcgi (.../tags/lighttpd-1.4.16) (revision 0)
402 +++ tests/docroot/www/404.fcgi (.../branches/lighttpd-1.4.x) (revision 1922)
405 +#use CGI qw/:standard/;
406 +use CGI::Fast qw(:standard);
408 +while (new CGI::Fast) {
409 + my $request_uri = $ENV{'REQUEST_URI'};
410 + print (STDERR "REQUEST_URI: $request_uri\n");
411 + if ($request_uri =~ m/^\/dynamic\/200\// ) {
412 + print header ( -status => 200,
413 + -type => 'text/plain' );
414 + print ("found here\n");
416 + elsif ($request_uri =~ m|^/dynamic/302/| ) {
417 + print header( -status=>302,
418 + -location => 'http://www.example.org/');
420 + elsif ($request_uri =~ m/^\/dynamic\/404\// ) {
421 + print header ( -status => 404
422 + -type => 'text/plain' );
423 + print ("Not found here\n");
426 + print header ( -status => 500,
427 + -type => 'text/plain');
432 Property changes on: tests/docroot/www/404.fcgi
433 ___________________________________________________________________
437 Index: tests/core-404-handler.t
438 ===================================================================
439 --- tests/core-404-handler.t (.../tags/lighttpd-1.4.16) (revision 0)
440 +++ tests/core-404-handler.t (.../branches/lighttpd-1.4.x) (revision 1922)
444 +# combinations we have to test:
446 +# 404-handler -> static file (verify content)
447 +# 404-handler -> fastcgi
449 +# returning 302 + Location
451 +# returning no status -> 200
454 + # add current source dir to the include-path
455 + # we need this for make distcheck
456 + (my $srcdir = $0) =~ s#/[^/]+$#/#;
457 + unshift @INC, $srcdir;
462 +use Test::More tests => 8;
465 +my $tf = LightyTest->new();
467 +$tf->{CONFIGFILE} = '404-handler.conf';
469 +ok($tf->start_proc == 0, "Starting lighttpd") or die();
471 +$t->{REQUEST} = ( <<EOF
472 +GET /static/notfound HTTP/1.0
475 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "static not found\n" } ];
476 +ok($tf->handle_http($t) == 0, '404 handler => static');
481 +$t->{REQUEST} = ( <<EOF
482 +GET /dynamic/200/notfound HTTP/1.0
485 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
486 +ok($tf->handle_http($t) == 0, '404 handler => dynamic(200)');
488 +$t->{REQUEST} = ( <<EOF
489 +GET /dynamic/302/notfound HTTP/1.0
492 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => "http://www.example.org/" } ];
493 +ok($tf->handle_http($t) == 0, '404 handler => dynamic(302)');
495 +$t->{REQUEST} = ( <<EOF
496 +GET /dynamic/404/notfound HTTP/1.0
499 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "Not found here\n" } ];
500 +ok($tf->handle_http($t) == 0, '404 handler => dynamic(404)');
502 +$t->{REQUEST} = ( <<EOF
503 +GET /dynamic/nostatus/notfound HTTP/1.0
506 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
507 +ok($tf->handle_http($t) == 0, '404 handler => dynamic(nostatus)');
509 +$t->{REQUEST} = ( <<EOF
510 +GET /send404.pl HTTP/1.0
513 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "send404\n" } ];
514 +ok($tf->handle_http($t) == 0, '404 generated by CGI should stay 404');
516 +ok($tf->stop_proc == 0, "Stopping lighttpd");
518 Index: doc/lighttpd.conf
519 ===================================================================
520 --- doc/lighttpd.conf (.../tags/lighttpd-1.4.16) (revision 1922)
521 +++ doc/lighttpd.conf (.../branches/lighttpd-1.4.x) (revision 1922)
524 ## a static document-root, for virtual-hosting take look at the
525 ## server.virtual-* options
526 -server.document-root = "/www/pages/"
527 +server.document-root = "/srv/www/htdocs/"
529 ## where to send error-messages to
530 -server.errorlog = "/www/logs/lighttpd.error.log"
531 +server.errorlog = "/var/log/lighttpd/error.log"
533 # files to check for if .../ is requested
534 index-file.names = ( "index.php", "index.html",
536 ".wmv" => "video/x-ms-wmv",
537 ".bz2" => "application/x-bzip",
538 ".tbz" => "application/x-bzip-compressed-tar",
539 - ".tar.bz2" => "application/x-bzip-compressed-tar"
540 + ".tar.bz2" => "application/x-bzip-compressed-tar",
541 + # default mime type
542 + "" => "application/octet-stream",
545 # Use the "Content-Type" extended attribute to obtain mime type if possible
547 # server.tag = "lighttpd"
549 #### accesslog module
550 -accesslog.filename = "/www/logs/access.log"
551 +accesslog.filename = "/var/log/lighttpd/access.log"
553 ## deny access the file-extensions
558 ## bind to localhost (default: all interfaces)
559 -#server.bind = "grisu.home.kneschke.de"
560 +#server.bind = "127.0.0.1"
562 ## error-handler for status 404
563 #server.error-handler-404 = "/error-handler.html"
564 @@ -158,15 +160,16 @@
566 ## virtual-server-root + http-host + virtual-server-docroot
568 -#simple-vhost.server-root = "/home/weigon/wwwroot/servers/"
569 -#simple-vhost.default-host = "grisu.home.kneschke.de"
570 -#simple-vhost.document-root = "/pages/"
571 +#simple-vhost.server-root = "/srv/www/vhosts/"
572 +#simple-vhost.default-host = "www.example.org"
573 +#simple-vhost.document-root = "/htdocs/"
577 ## Format: <errorfile-prefix><status-code>.html
578 ## -> ..../status-404.html for 'File not found'
579 -#server.errorfile-prefix = "/home/weigon/projects/lighttpd/doc/status-"
580 +#server.errorfile-prefix = "/usr/share/lighttpd/errors/status-"
581 +#server.errorfile-prefix = "/srv/www/errors/status-"
583 ## virtual directory listings
584 #dir-listing.activate = "enable"
586 #server.groupname = "wwwrun"
589 -#compress.cache-dir = "/tmp/lighttpd/cache/compress/"
590 +#compress.cache-dir = "/var/cache/lighttpd/compress/"
591 #compress.filetype = ("text/plain", "text/html")
595 #fastcgi.server = ( ".php" =>
598 -# "socket" => "/tmp/php-fastcgi.socket",
599 -# "bin-path" => "/usr/local/bin/php"
600 +# "socket" => "/var/run/lighttpd/php-fastcgi.socket",
601 +# "bin-path" => "/usr/local/bin/php-cgi"
608 #ssl.engine = "enable"
609 -#ssl.pemfile = "server.pem"
610 +#ssl.pemfile = "/etc/ssl/private/lighttpd.pem"
613 #status.status-url = "/server-status"
615 # %3 => subdomain 1 name
616 # %4 => subdomain 2 name
618 -#evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"
619 +#evhost.path-pattern = "/srv/www/vhosts/%3/htdocs/"
622 #expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")
623 @@ -279,14 +282,14 @@
626 #rrdtool.binary = "/usr/bin/rrdtool"
627 -#rrdtool.db-name = "/var/www/lighttpd.rrd"
628 +#rrdtool.db-name = "/var/lib/lighttpd/lighttpd.rrd"
631 #setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" )
632 #setenv.add-response-header = ( "X-Secret-Message" => "42" )
634 ## for mod_trigger_b4_dl
635 -# trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db"
636 +# trigger-before-download.gdbm-filename = "/var/lib/lighttpd/trigger.db"
637 # trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
638 # trigger-before-download.trigger-url = "^/trigger/"
639 # trigger-before-download.download-url = "^/download/"
641 ===================================================================
642 --- NEWS (.../tags/lighttpd-1.4.16) (revision 1922)
643 +++ NEWS (.../branches/lighttpd-1.4.x) (revision 1922)
649 + * added dir-listing.set-footer in mod_dirlisting (#1277)
650 + * fixed hardcoded font-sizes in mod_dirlisting (#1267)
651 + * fixed different ETag length on 32/64 platforms (#1279)
652 + * fixed compression of files < 128 bytes by disabling compression (#1241)
653 + * fixed mysql server reconnects (#518)
657 * added static-file.etags, etag.use-inode, etag.use-mtime, etag.use-size