commit 0f8ade8
default
·
2024-11-07 18:42:02 +0000 UTC
parent 916dc76
Propagate 'last-modified' and 'etag' fields while proxying. But does it work?
M
html.c
+7,
-1
1@@ -2796,7 +2796,8 @@ xs_str *html_notifications(snac *user, int skip, int show)
2
3
4 int html_get_handler(const xs_dict *req, const char *q_path,
5- char **body, int *b_size, char **ctype, xs_str **etag)
6+ char **body, int *b_size, char **ctype,
7+ xs_str **etag, xs_str **last_modified)
8 {
9 const char *accept = xs_dict_get(req, "accept");
10 int status = HTTP_STATUS_NOT_FOUND;
11@@ -3227,6 +3228,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
12
13 if (valid_status(status)) {
14 const char *ct = xs_dict_get(rsp, "content-type");
15+ const char *lm = xs_dict_get(rsp, "last-modified");
16+ const char *et = xs_dict_get(rsp, "etag");
17+
18+ if (lm) *last_modified = xs_dup(lm);
19+ if (et) *etag = xs_dup(et);
20
21 /* find the content-type in the static mime types,
22 and return that value instead of ct, which will
M
httpd.c
+4,
-1
1@@ -278,6 +278,7 @@ void httpd_connection(FILE *f)
2 xs *q_path = NULL;
3 xs *payload = NULL;
4 xs *etag = NULL;
5+ xs *last_modified = NULL;
6 int p_size = 0;
7 const char *p;
8 int fcgi_id;
9@@ -329,7 +330,7 @@ void httpd_connection(FILE *f)
10 #endif /* NO_MASTODON_API */
11
12 if (status == 0)
13- status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag);
14+ status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag, &last_modified);
15 }
16 else
17 if (strcmp(method, "POST") == 0) {
18@@ -423,6 +424,8 @@ void httpd_connection(FILE *f)
19
20 if (!xs_is_null(etag))
21 headers = xs_dict_append(headers, "etag", etag);
22+ if (!xs_is_null(last_modified))
23+ headers = xs_dict_append(headers, "last-modified", last_modified);
24
25 /* if there are any additional headers, add them */
26 const xs_dict *more_headers = xs_dict_get(srv_config, "http_headers");
M
snac.h
+3,
-1
1@@ -349,7 +349,9 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2 const char *title, const char *page, int utl, const char *error);
3
4 int html_get_handler(const xs_dict *req, const char *q_path,
5- char **body, int *b_size, char **ctype, xs_str **etag);
6+ char **body, int *b_size, char **ctype,
7+ xs_str **etag, xs_str **last_modified);
8+
9 int html_post_handler(const xs_dict *req, const char *q_path,
10 char *payload, int p_size,
11 char **body, int *b_size, char **ctype);