summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2023-07-02 11:11:01 +0200
committerGravatar default2023-07-02 11:11:01 +0200
commitd343b40ee553de8d98c18d3547e6c9b12ab96b48 (patch)
tree2f2d9ab495d2ad4e8187f31530d8019968b905bf /html.c
parentFixed footer link. (diff)
downloadsnac2-d343b40ee553de8d98c18d3547e6c9b12ab96b48.tar.gz
snac2-d343b40ee553de8d98c18d3547e6c9b12ab96b48.tar.xz
snac2-d343b40ee553de8d98c18d3547e6c9b12ab96b48.zip
Added HTTP caching to static data.
Diffstat (limited to 'html.c')
-rw-r--r--html.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/html.c b/html.c
index 7a0c805..425df4b 100644
--- a/html.c
+++ b/html.c
@@ -226,7 +226,7 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
226 int size; 226 int size;
227 227
228 /* try to open the user css */ 228 /* try to open the user css */
229 if (!valid_status(static_get(snac, "style.css", &css, &size))) { 229 if (!valid_status(static_get(snac, "style.css", &css, &size, NULL, NULL))) {
230 /* it's not there; try to open the server-wide css */ 230 /* it's not there; try to open the server-wide css */
231 FILE *f; 231 FILE *f;
232 xs *g_css_fn = xs_fmt("%s/style.css", srv_basedir); 232 xs *g_css_fn = xs_fmt("%s/style.css", srv_basedir);
@@ -1542,7 +1542,7 @@ xs_str *html_notifications(snac *snac)
1542 1542
1543 1543
1544int html_get_handler(const xs_dict *req, const char *q_path, 1544int html_get_handler(const xs_dict *req, const char *q_path,
1545 char **body, int *b_size, char **ctype) 1545 char **body, int *b_size, char **ctype, xs_str **etag)
1546{ 1546{
1547 char *accept = xs_dict_get(req, "accept"); 1547 char *accept = xs_dict_get(req, "accept");
1548 int status = 404; 1548 int status = 404;
@@ -1695,10 +1695,12 @@ int html_get_handler(const xs_dict *req, const char *q_path,
1695 char *id = xs_list_get(l, 1); 1695 char *id = xs_list_get(l, 1);
1696 int sz; 1696 int sz;
1697 1697
1698 if (valid_status(static_get(&snac, id, body, &sz))) { 1698 status = static_get(&snac, id, body, &sz,
1699 xs_dict_get(req, "if-none-match"), etag);
1700
1701 if (valid_status(status)) {
1699 *b_size = sz; 1702 *b_size = sz;
1700 *ctype = xs_mime_by_ext(id); 1703 *ctype = xs_mime_by_ext(id);
1701 status = 200;
1702 } 1704 }
1703 } 1705 }
1704 else 1706 else