Changeset 1874
- Timestamp:
- 06/15/2007 03:51:16 PM (14 months ago)
- Location:
- branches/lighttpd-1.4.x
- Files:
-
- 7 modified
-
NEWS (modified) (1 diff)
-
src/base.h (modified) (1 diff)
-
src/configfile.c (modified) (5 diffs)
-
src/etag.c (modified) (1 diff)
-
src/etag.h (modified) (1 diff)
-
src/mod_staticfile.c (modified) (6 diffs)
-
src/stat_cache.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/lighttpd-1.4.x/NEWS
r1873 r1874 6 6 - 1.4.16 - 7 7 8 * added static-file.etags, etag.use-inode, etag.use-mtime, etag.use-size 9 to customize the generation of ETags for static files. (#1209) 10 (patch by <Yusufg@gmail.com>) 8 11 * fixed typecast of NULL on execl() (#1235) 12 (patch by F. Denis) 9 13 * fixed circumventing url.access-deny by trailing slash (#1230) 10 14 * fixed crash on duplicate headers with trailing WS (#1232) -
branches/lighttpd-1.4.x/src/base.h
r1664 r1874 270 270 unsigned short is_ssl; 271 271 unsigned short allow_http11; 272 unsigned short etag_use_inode; 273 unsigned short etag_use_mtime; 274 unsigned short etag_use_size; 272 275 unsigned short force_lowercase_filenames; /* if the FS is case-insensitive, force all files to lower-case */ 273 276 unsigned short max_request_size; -
branches/lighttpd-1.4.x/src/configfile.c
r1739 r1874 90 90 { "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 46 */ 91 91 { "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 47 */ 92 92 { "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 48 */ 93 { "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 49 */ 94 { "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 50 */ 93 95 { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, 94 96 { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, … … 163 165 s->kbytes_per_second = 0; 164 166 s->allow_http11 = 1; 167 s->etag_use_inode = 1; 168 s->etag_use_mtime = 1; 169 s->etag_use_size = 1; 165 170 s->range_requests = 1; 166 171 s->force_lowercase_filenames = 0; … … 207 212 cv[46].destination = s->ssl_cipher_list; 208 213 cv[47].destination = &(s->ssl_use_sslv2); 214 cv[48].destination = &(s->etag_use_inode); 215 cv[49].destination = &(s->etag_use_mtime); 216 cv[50].destination = &(s->etag_use_size); 209 217 210 218 srv->config_storage[i] = s; … … 281 289 PATCH(ssl_cipher_list); 282 290 PATCH(ssl_use_sslv2); 283 284 291 PATCH(etag_use_inode); 292 PATCH(etag_use_mtime); 293 PATCH(etag_use_size); 294 285 295 return 0; 286 296 } … … 324 334 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("mimetype.use-xattr"))) { 325 335 PATCH(use_xattr); 336 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-inode"))) { 337 PATCH(etag_use_inode); 338 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-mtime"))) { 339 PATCH(etag_use_mtime); 340 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-size"))) { 341 PATCH(etag_use_size); 326 342 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.pemfile"))) { 327 343 PATCH(ssl_pemfile); -
branches/lighttpd-1.4.x/src/etag.c
r1371 r1874 9 9 } 10 10 11 int etag_create(buffer *etag, struct stat *st) { 12 buffer_copy_off_t(etag, st->st_ino); 13 buffer_append_string_len(etag, CONST_STR_LEN("-")); 14 buffer_append_off_t(etag, st->st_size); 15 buffer_append_string_len(etag, CONST_STR_LEN("-")); 16 buffer_append_long(etag, st->st_mtime); 11 int etag_create(buffer *etag, struct stat *st,etag_flags_t flags) { 12 if (0 == flags) return 0; 13 14 if (flags & ETAG_USE_INODE) { 15 buffer_copy_off_t(etag, st->st_ino); 16 buffer_append_string_len(etag, CONST_STR_LEN("-")); 17 } 18 19 if (flags & ETAG_USE_SIZE) { 20 buffer_append_off_t(etag, st->st_size); 21 buffer_append_string_len(etag, CONST_STR_LEN("-")); 22 } 23 24 if (flags & ETAG_USE_MTIME) { 25 buffer_append_long(etag, st->st_mtime); 26 } 17 27 18 28 return 0; -
branches/lighttpd-1.4.x/src/etag.h
r1371 r1874 8 8 #include "buffer.h" 9 9 10 typedef enum { ETAG_USE_INODE = 1, ETAG_USE_MTIME = 2, ETAG_USE_SIZE = 4 } etag_flags_t; 11 10 12 int etag_is_equal(buffer *etag, const char *matches); 11 int etag_create(buffer *etag, struct stat *st );13 int etag_create(buffer *etag, struct stat *st, etag_flags_t flags); 12 14 int etag_mutate(buffer *mut, buffer *etag); 13 15 -
branches/lighttpd-1.4.x/src/mod_staticfile.c
r1725 r1874 26 26 typedef struct { 27 27 array *exclude_ext; 28 unsigned short etags_used; 28 29 } plugin_config; 29 30 … … 83 84 config_values_t cv[] = { 84 85 { "static-file.exclude-extensions", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 0 */ 86 { "static-file.etags", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */ 85 87 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } 86 88 }; … … 95 97 s = calloc(1, sizeof(plugin_config)); 96 98 s->exclude_ext = array_init(); 99 s->etags_used = 1; 97 100 98 101 cv[0].destination = s->exclude_ext; 102 cv[1].destination = &(s->etags_used); 99 103 100 104 p->config_storage[i] = s; … … 115 119 116 120 PATCH(exclude_ext); 121 PATCH(etags_used); 117 122 118 123 /* skip the first, the global context */ … … 130 135 if (buffer_is_equal_string(du->key, CONST_STR_LEN("static-file.exclude-extensions"))) { 131 136 PATCH(exclude_ext); 132 } 137 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("static-file.etags"))) { 138 PATCH(etags_used); 139 } 133 140 } 134 141 } … … 447 454 448 455 if (allow_caching) { 449 if (NULL == array_get_element(con->response.headers, "ETag")) { 450 /* generate e-tag */ 451 etag_mutate(con->physical.etag, sce->etag); 452 453 response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag)); 456 etag_flags_t flags; 457 458 flags = (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0); 459 460 if (p->conf.etags_used && flags != 0 && !buffer_is_empty(sce->etag)) { 461 if (NULL == array_get_element(con->response.headers, "ETag")) { 462 /* generate e-tag */ 463 etag_mutate(con->physical.etag, sce->etag); 464 465 response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag)); 466 } 454 467 } 455 468 -
branches/lighttpd-1.4.x/src/stat_cache.c
r1863 r1874 609 609 } 610 610 } 611 etag_create(sce->etag, &(sce->st)); 611 etag_create(sce->etag, &(sce->st), 612 (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0)); 612 613 #ifdef HAVE_XATTR 613 614 if (con->conf.use_xattr && buffer_is_empty(sce->content_type)) { … … 616 617 #endif 617 618 } else if (S_ISDIR(st.st_mode)) { 618 etag_create(sce->etag, &(sce->st)); 619 etag_create(sce->etag, &(sce->st), 620 (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0)); 619 621 } 620 622

