diff --git a/html.c b/html.c index 1e09c5e..b5d9148 100644 --- a/html.c +++ b/html.c @@ -2796,7 +2796,8 @@ xs_str *html_notifications(snac *user, int skip, int show) int html_get_handler(const xs_dict *req, const char *q_path, - char **body, int *b_size, char **ctype, xs_str **etag) + char **body, int *b_size, char **ctype, + xs_str **etag, xs_str **last_modified) { const char *accept = xs_dict_get(req, "accept"); int status = HTTP_STATUS_NOT_FOUND; @@ -3227,6 +3228,11 @@ int html_get_handler(const xs_dict *req, const char *q_path, if (valid_status(status)) { const char *ct = xs_dict_get(rsp, "content-type"); + const char *lm = xs_dict_get(rsp, "last-modified"); + const char *et = xs_dict_get(rsp, "etag"); + + if (lm) *last_modified = xs_dup(lm); + if (et) *etag = xs_dup(et); /* find the content-type in the static mime types, and return that value instead of ct, which will diff --git a/httpd.c b/httpd.c index 2fe9d6b..1613e1f 100644 --- a/httpd.c +++ b/httpd.c @@ -278,6 +278,7 @@ void httpd_connection(FILE *f) xs *q_path = NULL; xs *payload = NULL; xs *etag = NULL; + xs *last_modified = NULL; int p_size = 0; const char *p; int fcgi_id; @@ -329,7 +330,7 @@ void httpd_connection(FILE *f) #endif /* NO_MASTODON_API */ if (status == 0) - status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag); + status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag, &last_modified); } else if (strcmp(method, "POST") == 0) { @@ -423,6 +424,8 @@ void httpd_connection(FILE *f) if (!xs_is_null(etag)) headers = xs_dict_append(headers, "etag", etag); + if (!xs_is_null(last_modified)) + headers = xs_dict_append(headers, "last-modified", last_modified); /* if there are any additional headers, add them */ const xs_dict *more_headers = xs_dict_get(srv_config, "http_headers"); diff --git a/snac.h b/snac.h index 27c3d68..3c3b044 100644 --- a/snac.h +++ b/snac.h @@ -349,7 +349,9 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, const char *title, const char *page, int utl, const char *error); int html_get_handler(const xs_dict *req, const char *q_path, - char **body, int *b_size, char **ctype, xs_str **etag); + char **body, int *b_size, char **ctype, + xs_str **etag, xs_str **last_modified); + int html_post_handler(const xs_dict *req, const char *q_path, char *payload, int p_size, char **body, int *b_size, char **ctype);