summaryrefslogtreecommitdiff
path: root/src/mod_expire.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2020-01-12 21:51:12 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2020-07-08 19:54:29 -0400
commit7c7f8c467c8b6af678faf10078d7a59c3856045a (patch)
tree491b6c04ef37043a51e230825aab4deb0a347c47 /src/mod_expire.c
parentcc2134c88badd541cfe1954c80e371db5f28ede3 (diff)
downloadlighttpd-git-7c7f8c467c8b6af678faf10078d7a59c3856045a.tar.gz
[multiple] split con, request (very large change)
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().
Diffstat (limited to 'src/mod_expire.c')
-rw-r--r--src/mod_expire.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mod_expire.c b/src/mod_expire.c
index b9088f70..a098efb3 100644
--- a/src/mod_expire.c
+++ b/src/mod_expire.c
@@ -184,11 +184,11 @@ static void mod_expire_merge_config(plugin_config * const pconf, const config_pl
} while ((++cpv)->k_id != -1);
}
-static void mod_expire_patch_config(connection * const con, plugin_data * const p) {
+static void mod_expire_patch_config(request_st * const r, plugin_data * const p) {
p->conf = p->defaults; /* copy small struct instead of memcpy() */
/*memcpy(&p->conf, &p->defaults, sizeof(plugin_config));*/
for (int i = 1, used = p->nconfig; i < used; ++i) {
- if (config_check_cond(con, (uint32_t)p->cvlist[i].k_id))
+ if (config_check_cond(r, (uint32_t)p->cvlist[i].k_id))
mod_expire_merge_config(&p->conf, p->cvlist + p->cvlist[i].v.u2[0]);
}
}
@@ -268,31 +268,31 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) {
return HANDLER_GO_ON;
}
-CONNECTION_FUNC(mod_expire_handler) {
+REQUEST_FUNC(mod_expire_handler) {
plugin_data *p = p_d;
const buffer *vb;
const data_string *ds;
/* Add caching headers only to http_status 200 OK or 206 Partial Content */
- if (con->http_status != 200 && con->http_status != 206) return HANDLER_GO_ON;
+ if (r->http_status != 200 && r->http_status != 206) return HANDLER_GO_ON;
/* Add caching headers only to GET or HEAD requests */
- if (!http_method_get_or_head(con->request.http_method)) return HANDLER_GO_ON;
+ if (!http_method_get_or_head(r->http_method)) return HANDLER_GO_ON;
/* Add caching headers only if not already present */
- vb = http_header_response_get(con, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"));
+ vb = http_header_response_get(r, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"));
if (NULL != vb) return HANDLER_GO_ON;
- if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
+ if (buffer_is_empty(&r->uri.path)) return HANDLER_GO_ON;
- mod_expire_patch_config(con, p);
+ mod_expire_patch_config(r, p);
/* check expire.url */
ds = p->conf.expire_url
- ? (const data_string *)array_match_key_prefix(p->conf.expire_url, con->uri.path)
+ ? (const data_string *)array_match_key_prefix(p->conf.expire_url, &r->uri.path)
: NULL;
/* check expire.mimetypes (if no match with expire.url) */
if (NULL == ds) {
if (NULL == p->conf.expire_mimetypes) return HANDLER_GO_ON;
- vb = http_header_response_get(con, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"));
+ vb = http_header_response_get(r, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"));
ds = (NULL != vb)
? (const data_string *)array_match_key_prefix(p->conf.expire_mimetypes, vb)
: (const data_string *)array_get_element_klen(p->conf.expire_mimetypes, CONST_STR_LEN(""));
@@ -306,7 +306,7 @@ CONNECTION_FUNC(mod_expire_handler) {
expires += cur_ts;
}
else { /* modification */
- stat_cache_entry *sce = stat_cache_get_entry(con->physical.path);
+ stat_cache_entry *sce = stat_cache_get_entry(&r->physical.path);
/* can't set modification-based expire if mtime is not available */
if (NULL == sce) return HANDLER_GO_ON;
expires += sce->st.st_mtime;
@@ -315,17 +315,17 @@ CONNECTION_FUNC(mod_expire_handler) {
/* expires should be at least cur_ts */
if (expires < cur_ts) expires = cur_ts;
- buffer * const tb = con->srv->tmp_buf;
+ buffer * const tb = r->tmp_buf;
/* HTTP/1.0 */
buffer_clear(tb);
buffer_append_strftime(tb, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(expires)));
- http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("Expires"), CONST_BUF_LEN(tb));
+ http_header_response_set(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Expires"), CONST_BUF_LEN(tb));
/* HTTP/1.1 */
buffer_copy_string_len(tb, CONST_STR_LEN("max-age="));
buffer_append_int(tb, expires - cur_ts); /* as expires >= cur_ts the difference is >= 0 */
- http_header_response_set(con, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(tb));
+ http_header_response_set(r, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(tb));
return HANDLER_GO_ON;
}