diff -bur trunk/src/base.h trunk_patched/src/base.h
|
old
|
new
|
|
| 33 | 33 | #include "fdevent.h" |
| 34 | 34 | #include "sys-socket.h" |
| 35 | 35 | #include "http_req.h" |
| | 36 | #include "etag.h" |
| 36 | 37 | |
| 37 | 38 | #if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H |
| 38 | 39 | # define USE_OPENSSL |
| … |
… |
|
| 303 | 304 | unsigned short use_ipv6; |
| 304 | 305 | unsigned short is_ssl; |
| 305 | 306 | unsigned short allow_http11; |
| | 307 | unsigned short etag_use_inode; |
| | 308 | unsigned short etag_use_mtime; |
| | 309 | unsigned short etag_use_size; |
| 306 | 310 | unsigned short force_lowercase_filenames; /* if the FS is case-insensitive, force all files to lower-case */ |
| 307 | 311 | unsigned int max_request_size; |
| 308 | 312 | |
| … |
… |
|
| 448 | 452 | GTimeVal timestamps[TIME_LAST_ELEMENT]; /**< used by timing.h */ |
| 449 | 453 | #endif |
| 450 | 454 | |
| | 455 | /* etag handling */ |
| | 456 | etag_flags_t etag_flags; |
| | 457 | |
| 451 | 458 | int conditional_is_valid[COMP_LAST_ELEMENT]; |
| 452 | 459 | } connection; |
| 453 | 460 | |
diff -bur trunk/src/configfile.c trunk_patched/src/configfile.c
|
old
|
new
|
|
| 99 | 99 | { "debug.log-timing", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 51 */ |
| 100 | 100 | { "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 52 */ |
| 101 | 101 | { "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 53 */ |
| | 102 | { "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 54 */ |
| | 103 | { "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 55 */ |
| | 104 | { "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 56 */ |
| 102 | 105 | |
| 103 | 106 | { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, |
| 104 | 107 | { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, |
| … |
… |
|
| 180 | 183 | s->kbytes_per_second = 0; |
| 181 | 184 | s->allow_http11 = 1; |
| 182 | 185 | s->range_requests = 1; |
| | 186 | s->etag_use_inode = 1; |
| | 187 | s->etag_use_mtime = 1; |
| | 188 | s->etag_use_size = 1; |
| 183 | 189 | s->force_lowercase_filenames = 0; |
| 184 | 190 | s->global_kbytes_per_second = 0; |
| 185 | 191 | s->global_bytes_per_second_cnt = 0; |
| … |
… |
|
| 225 | 231 | cv[50].destination = &(s->max_connection_idle); |
| 226 | 232 | cv[52].destination = s->ssl_cipher_list; |
| 227 | 233 | cv[53].destination = &(s->ssl_use_sslv2); |
| | 234 | cv[54].destination = &(s->etag_use_inode); |
| | 235 | cv[55].destination = &(s->etag_use_mtime); |
| | 236 | cv[56].destination = &(s->etag_use_size); |
| 228 | 237 | |
| 229 | 238 | srv->config_storage[i] = s; |
| 230 | 239 | |
| … |
… |
|
| 297 | 306 | PATCH(ssl_ca_file); |
| 298 | 307 | PATCH(ssl_cipher_list); |
| 299 | 308 | PATCH(ssl_use_sslv2); |
| | 309 | |
| | 310 | PATCH(etag_use_inode); |
| | 311 | PATCH(etag_use_mtime); |
| | 312 | PATCH(etag_use_size); |
| 300 | 313 | return 0; |
| 301 | 314 | } |
| 302 | 315 | |
| … |
… |
|
| 342 | 355 | PATCH(max_connection_idle); |
| 343 | 356 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("mimetype.use-xattr"))) { |
| 344 | 357 | PATCH(use_xattr); |
| | 358 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-inode"))) { |
| | 359 | PATCH(etag_use_inode); |
| | 360 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-mtime"))) { |
| | 361 | PATCH(etag_use_mtime); |
| | 362 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("etag.use-size"))) { |
| | 363 | PATCH(etag_use_size); |
| 345 | 364 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.pemfile"))) { |
| 346 | 365 | PATCH(ssl_pemfile); |
| 347 | 366 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("ssl.ca-file"))) { |
| … |
… |
|
| 385 | 404 | } |
| 386 | 405 | } |
| 387 | 406 | } |
| | 407 | con->etag_flags = (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | |
| | 408 | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | |
| | 409 | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0); |
| 388 | 410 | |
| 389 | 411 | return 0; |
| 390 | 412 | } |
diff -bur trunk/src/etag.c trunk_patched/src/etag.c
|
old
|
new
|
|
| 9 | 9 | return 0; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | | int etag_create(buffer *etag, struct stat *st) { |
| 13 | | buffer_copy_off_t(etag, st->st_ino); |
| | 12 | int etag_create(buffer *etag, struct stat *st, etag_flags_t flags) { |
| | 13 | |
| | 14 | if (0 == flags) return 0; |
| | 15 | |
| | 16 | buffer_reset(etag); |
| | 17 | |
| | 18 | if (flags & ETAG_USE_INODE) { |
| | 19 | buffer_append_off_t(etag, st->st_ino); |
| 14 | 20 | buffer_append_string_len(etag, CONST_STR_LEN("-")); |
| | 21 | } |
| | 22 | |
| | 23 | if (flags & ETAG_USE_SIZE) { |
| 15 | 24 | buffer_append_off_t(etag, st->st_size); |
| 16 | 25 | buffer_append_string_len(etag, CONST_STR_LEN("-")); |
| | 26 | } |
| | 27 | |
| | 28 | if (flags & ETAG_USE_MTIME) { |
| 17 | 29 | buffer_append_long(etag, st->st_mtime); |
| | 30 | } |
| 18 | 31 | |
| 19 | 32 | return 0; |
| 20 | 33 | } |
diff -bur trunk/src/etag.h trunk_patched/src/etag.h
|
old
|
new
|
|
| 6 | 6 | |
| 7 | 7 | #include "buffer.h" |
| 8 | 8 | |
| | 9 | typedef enum { ETAG_USE_INODE = 1, ETAG_USE_MTIME = 2, ETAG_USE_SIZE = 4 } etag_flags_t; |
| | 10 | |
| 9 | 11 | LI_API int etag_is_equal(buffer *etag, const char *matches); |
| 10 | | LI_API int etag_create(buffer *etag, struct stat *st); |
| | 12 | LI_API int etag_create(buffer *etag, struct stat *st, etag_flags_t flags); |
| 11 | 13 | LI_API int etag_mutate(buffer *mut, buffer *etag); |
| 12 | 14 | |
| 13 | 15 | |
diff -bur trunk/src/stat_cache.c trunk_patched/src/stat_cache.c
|
old
|
new
|
|
| 470 | 470 | break; |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | | etag_create(sce->etag, &(sce->st)); |
| | 473 | etag_create(sce->etag, &(sce->st), con->etag_flags); |
| 474 | 474 | #ifdef HAVE_XATTR |
| 475 | 475 | if (con->conf.use_xattr && buffer_is_empty(sce->content_type)) { |
| 476 | 476 | stat_cache_attr_get(sce->content_type, name->ptr); |
| 477 | 477 | } |
| 478 | 478 | #endif |
| 479 | 479 | } else if (S_ISDIR(st.st_mode)) { |
| 480 | | etag_create(sce->etag, &(sce->st)); |
| | 480 | etag_create(sce->etag, &(sce->st), con->etag_flags); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | *ret_sce = sce; |