summaryrefslogtreecommitdiff
path: root/src/mod_expire.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] _WIN32 __declspec(dllexport) *_plugin_initGlenn Strauss2023-05-031-0/+1
| | | | _WIN32 __declspec(dllexport) on mod_*_plugin_init()
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-1/+1
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [multiple] employ ck_realloc_u32() shared codeGlenn Strauss2022-12-101-2/+2
| | | | employ ck_realloc_u32() shared code to slightly reduce code size
* [multiple] mark mod_*_plugin_init() funcs coldGlenn Strauss2022-12-071-0/+1
|
* [multiple] application/javascript text/javascriptGlenn Strauss2022-05-261-1/+13
| | | | | | | | | | translate MIME type "application/javascript" to "text/javascript" (if required, type may still be overwritten by mod_setenv or mod_magnet) x-ref: "Updates to ECMAScript Media Types" https://www.rfc-editor.org/rfc/rfc9239
* [multiple] recognize HTTP QUERY methodGlenn Strauss2022-05-051-4/+6
| | | | | x-ref: https://www.ietf.org/id/draft-ietf-httpbis-safe-method-w-body-02.html
* [core] quiet compiler warningsGlenn Strauss2021-09-041-1/+1
| | | | | | | | | | cast away signedness warning in request_check_hostname() mod_gnutls https_add_ssl_client_entries crts allocated if crt_size != 0 (which is already checked earlier in routine) report from FaceBook Infer static analysis tool (https://fbinfer.com/) - quiet dead store warnings - check return != NULL from allocation funcs
* [multiple] Y2038 32-bit signed time_t mitigationsGlenn Strauss2021-09-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most OS platforms have already provided solutions to Y2038 32-bit signed time_t 5 - 10 years ago (or more!) Notable exceptions are Linux i686 and FreeBSD i386. Since 32-bit systems tend to be embedded systems, and since many distros take years to pick up new software, this commit aims to provide Y2038 mitigations for lighttpd running on 32-bit systems with Y2038-unsafe 32-bit signed time_t * Y2038: lighttpd 1.4.60 and later report Y2038 safety $ lighttpd -V + Y2038 support # Y2038-SAFE $ lighttpd -V - Y2038 support (unsafe 32-bit signed time_t) # Y2038-UNSAFE * Y2038: general platform info * Y2038-SAFE: lighttpd 64-bit builds on platforms using 64-bit time_t - all major 64-bit platforms (known to this author) use 64-bit time_t * Y2038-SAFE: lighttpd 32-bit builds on platforms using 64-bit time_t - Linux x32 ABI (different from i686) - FreeBSD all 32-bit and 64-bit architectures *except* 32-bit i386 - NetBSD 6.0 (released Oct 2012) all 32-bit and 64-bit architectures - OpenBSD 5.5 (released May 2014) all 32-bit and 64-bit architectures - Microsoft Windows XP and Visual Studio 2005 (? unsure ?) Another reference suggests Visual Studio 2015 defaults to 64-bit time_t - MacOS 10.15 Catalina (released 2019) drops support for 32-bit apps * Y2038-SAFE: lighttpd 32-bit builds on platforms using 32-bit unsigned time_t - e.g. OpenVMS (unknown if lighttpd builds on this platform) * Y2038-UNSAFE: lighttpd 32-bit builds on platforms using 32-bit signed time_t - Linux 32-bit (including i686) - glibc 32-bit library support not yet available for 64-bit time_t - https://sourceware.org/glibc/wiki/Y2038ProofnessDesign - Linux kernel 5.6 on 32-bit platforms does support 64-bit time_t https://itsubuntu.com/linux-kernel-5-6-to-fix-the-year-2038-issue-unix-y2k/ - https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html "Note: at this point, 64-bit time support in dual-time configurations is work-in-progress, so for these configurations, the public API only makes the 32-bit time support available. In a later change, the public API will allow user code to choose the time size for a given compilation unit." - compiling with -D_TIME_BITS=64 currently has no effect - glibc recent (Jul 2021) mailing list discussion - https://public-inbox.org/bug-gnulib/878s2ozq70.fsf@oldenburg.str.redhat.com/T/ - FreeBSD i386 - DragonFlyBSD 32-bit * Y2038 mitigations attempted on Y2038-UNSAFE platforms (32-bit signed time_t) * lighttpd prefers system monotonic clock instead of realtime clock in places where realtime clock is not required * lighttpd treats negative time_t values as after 19 Jan 2038 03:14:07 GMT * (lighttpd presumes that lighttpd will not encounter dates before 1970 during normal operation.) * lighttpd casts struct stat st.st_mtime (and st.st_*time) through uint64_t to convert negative timestamps for comparisions with 64-bit timestamps (treating negative timestamp values as after 19 Jan 2038 03:14:07 GMT) * lighttpd provides unix_time64_t (int64_t) and * lighttpd provides struct unix_timespec64 (unix_timespec64_t) (struct timespec equivalent using unix_time64_t tv_sec member) * lighttpd provides gmtime64_r() and localtime64_r() wrappers for platforms 32-bit platforms using 32-bit time_t and lighttpd temporarily shifts the year in order to use gmtime_r() and localtime_r() (or gmtime() and localtime()) from standard libraries, before readjusting year and passing struct tm to formatting functions such as strftime() * lighttpd provides TIME64_CAST() macro to cast signed 32-bit time_t to unsigned 32-bit and then to unix_time64_t * Note: while lighttpd tries handle times past 19 Jan 2038 03:14:07 GMT on 32-bit platforms using 32-bit signed time_t, underlying libraries and underlying filesystems might not behave properly after 32-bit signed time_t overflows (19 Jan 2038 03:14:08 GMT). If a given 32-bit OS does not work properly using negative time_t values, then lighttpd likely will not work properly on that system. * Other references and blogs - https://en.wikipedia.org/wiki/Year_2038_problem - https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs - http://www.lieberbiber.de/2017/03/14/a-look-at-the-year-20362038-problems-and-time-proofness-in-various-systems/
* [core] http_date_time_append() convenience macroGlenn Strauss2021-08-271-3/+1
| | | | append IMF-fixdate time string to (buffer *)
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg
* [mod_expire] send only Cache-Control to >=HTTP/1.1Glenn Strauss2021-04-271-30/+48
| | | | | | | | | | | | | HTTP/1.1 dictates that Cache-Control overrides Expires if both present. Therefore, send only Cache-Control to HTTP/1.1 requests. This means that if an intermediary upgraded the request to HTTP/1.1, and the actual client sent HTTP/1.0, then the actual client might not understand Cache-Control when it may have understood Expires. RFC 2616 HTTP/1.1 was released June 1999, almost 22 years ago (as this comment is written) If a client today is sending HTTP/1.0, chances are the client does not cache. Avoid the overhead of formatting time for Expires to send both Cache-Control and Expires when the majority of clients are HTTP/1.1 or HTTP/2 (or later).
* [mod_expire] check for default if mime not foundGlenn Strauss2021-04-261-4/+9
| | | | check for default caching if mime-type not found in expire.mimetypes
* [mod_expire] accept time labels without plural 's'Glenn Strauss2021-04-251-41/+16
|
* [mod_expires,mod_webdav] fix truncated date stringGlenn Strauss2021-04-241-3/+3
| | | | (bug on master branch)
* [multiple] more reuse of http_date_time_to_str()Glenn Strauss2021-04-051-3/+4
|
* [multiple] strftime %F and %TGlenn Strauss2021-04-021-1/+1
| | | | strftime %F for %Y-%m-%d, and %T for %H:%M:%S
* [multiple] http_header APIs to reduce str copiesGlenn Strauss2021-03-261-15/+13
|
* [multiple] employ http_date.h, sys-time.hGlenn Strauss2020-12-241-2/+3
| | | | | - replace use of strptime() w/ implementation specialized for HTTP dates - use thread-safe gmtime_r(), localtime_r() (replace localtime, gmtime)
* [multiple] stat_cache_path_stat() for struct stGlenn Strauss2020-10-191-3/+3
| | | | stat_cache_path_stat() for cached (struct st *)
* [multiple] extend enum http_header_e listGlenn Strauss2020-10-111-1/+3
|
* [core] r->uri.path always set, though might be ""Glenn Strauss2020-07-081-2/+0
| | | | (might be "" if <backend>.server sets "fix-root-scriptname" => "enable")
* [multiple] split con, request (very large change)Glenn Strauss2020-07-081-14/+14
| | | | | | | | | | | | | | | | NB: r->tmp_buf == srv->tmp_buf (pointer is copied for quicker access) NB: request read and write chunkqueues currently point to connection chunkqueues; per-request and per-connection chunkqueues are not distinct from one another con->read_queue == r->read_queue con->write_queue == r->write_queue NB: in the future, a separate connection config may be needed for connection-level module hooks. Similarly, might need to have per-request chunkqueues separate from per-connection chunkqueues. Should probably also have a request_reset() which is distinct from connection_reset().
* [multiple] copy small struct instead of memcpy()Glenn Strauss2020-07-081-1/+2
| | | | when patching config
* [core] convenience macros to check req methodsGlenn Strauss2020-07-081-2/+1
|
* [multiple] generic config array type checkingGlenn Strauss2020-07-081-16/+2
|
* [mod_expire] parse config into structured dataGlenn Strauss2020-07-081-58/+48
|
* [multiple] stat_cache singletonGlenn Strauss2020-07-081-2/+1
|
* [multiple] extern log_epoch_secsGlenn Strauss2020-07-081-1/+1
| | | | replace srv->cur_ts
* [multiple] reduce direct use of srv->cur_tsGlenn Strauss2020-07-081-17/+15
|
* [multiple] connection hooks no longer get (srv *)Glenn Strauss2020-07-081-1/+2
| | | | (explicit (server *) not passed; available in con->srv)
* [multiple] prefer (connection *) to (srv *)Glenn Strauss2020-07-081-16/+12
| | | | | | | | convert all log_error_write() to log_error() and pass (log_error_st *) use con->errh in preference to srv->errh (even though currently same) avoid passing (server *) when previously used only for logging (errh)
* [multiple] plugin.c handles common FREE_FUNC codeGlenn Strauss2020-07-081-12/+0
| | | | (simpler for modules; less boilerplate to cut-n-paste)
* [mod_expire] use config_plugin_values_init()Glenn Strauss2020-05-231-166/+132
|
* [core] const char *name in struct pluginGlenn Strauss2020-05-231-3/+1
| | | | | | | | put void *data (always used) as first member of struct plugin add int nconfig member to PLUGIN_DATA calloc() inits p->data to NULL
* [core] simpler config_check_cond()Glenn Strauss2020-05-231-3/+2
| | | | | | | optimize for common case where condition has been evaluated for the request and a cached result exists (also: begin isolating data_config)
* [core] inline buffer as part of data_string valueGlenn Strauss2020-02-241-6/+6
| | | | (instead of value being (buffer *))
* [core] inline buffer key for *_patch_connection()Glenn Strauss2020-02-241-2/+2
| | | | | handle buffer key as part of DATA_UNSET in *_patch_connection() (instead of key being (buffer *))
* [core] inline buffer as part of DATA_UNSET keyGlenn Strauss2020-02-241-2/+2
| | | | (instead of key being (buffer *))
* [core] differentiate array_get_* for ro and rwGlenn Strauss2020-02-241-6/+6
| | | | | | array_get_element_klen() is now intended for read-only access array_get_data_unset() is used by config processing for r/w access array_get_buf_ptr() is used for r/w access to ds->value (string buffer)
* [stat_cache] separate func for symlink policy chkGlenn Strauss2019-04-291-3/+3
| | | | | Note: historical ToC-ToU race condition still exists in implementation server.follow-symlink = "disable" is not recommended (default: "enable")
* [multiple] cleaner calloc use in SETDEFAULTS_FUNCMohammed Sadiq2019-04-201-1/+1
| | | | | | | | github: closes #99 x-ref: "cleaner calloc use in SETDEFAULTS_FUNC" https://github.com/lighttpd/lighttpd1.4/pull/99
* [mod_expire] look up expire fallback "" explicitlyGlenn Strauss2019-01-211-1/+1
| | | | | | | equivalent to prior code, but more direct (legibile in code) to look up empty string than to walk array. Might be marginally faster to walk array when the list is short, but the lookup is also fairly quick in that case, too.
* [core] perf: simple, quick buffer_clear()Glenn Strauss2018-11-231-1/+1
| | | | | | | | | quickly clear buffer instead of buffer_string_set_length(b, 0) or buffer_reset(b). Avoids free() of large buffers about to be reused, or buffers that are module-scoped, persistent, and reused. (buffer_reset() should still be used with buffers in connection *con when the data in the buffers is supplied by external, untrusted source)
* [core] perf: skip redundant prepare copy callsGlenn Strauss2018-10-251-1/+1
| | | | | | | skip redundant calls to buffer_string_prepare_copy() when simply clearing buffer is sufficient, e.g. when a blanked buffer is desired before calling buffer_append_strftime(), which internally prepares buffer for the resultant formatted string
* [multiple] code reuse: employ array_match_*()Glenn Strauss2018-09-231-45/+18
|
* [core] abstraction layer for HTTP header manipGlenn Strauss2018-09-231-15/+17
| | | | | | http_header.[ch] convert existing calls to manip request/response headers convert existing calls to manip environment array (often header-related)
* [core] remove some unused header includesGlenn Strauss2017-03-281-1/+0
| | | | remove exposure of stdio.h in buffer.h for print_backtrace(), now static
* [config] more specific checks for array listsGlenn Strauss2017-03-081-0/+12
| | | | | | | | | | | | | More specific checks on contents of array lists. Each module using lists now does better checking on the types of values in the list (strings, integers, arrays/lists) This helps prevent misconfiguration of things like cgi.assign, fastcgi.server, and scgi.server, where source code might be served as static files if parenthesis are misplaced. x-ref: https://redmine.lighttpd.net/boards/2/topics/6571
* [mod_expire] expire by mimetype (fixes #423)Glenn Strauss2016-10-201-6/+71
| | | | | | | | | | | | | | | | | new directive expire.mimetypes for list of mimetypes and expirations mod_expire is now processed at the start of the response, and so now may be applied to all responses, including dynamic responses. mod_expire now applies only to GET and HEAD requests where the response status is 200 OK or 206 Partial Content, and for which no other modules or backend has already added a Cache-Control response header. expire.url takes precedence over expire.mimetypes x-ref: "Add expire by Mimetype" https://redmine.lighttpd.net/issues/423
* consistent inclusion of config.h at top of files (fixes #2073)Glenn Strauss2016-03-191-0/+2
| | | | | | From: Glenn Strauss <gstrauss@gluelogic.com> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3113 152afb58-edef-0310-8abb-c4023f1b3aa9