mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-28 07:33:37 +00:00
Propagate 'last-modified' and 'etag' fields while proxying.
But does it work?
This commit is contained in:
parent
916dc76332
commit
0f8ade8c60
3 changed files with 14 additions and 3 deletions
8
html.c
8
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
|
||||
|
|
5
httpd.c
5
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");
|
||||
|
|
4
snac.h
4
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);
|
||||
|
|
Loading…
Reference in a new issue