diff options
| author | 2024-11-07 19:42:02 +0100 | |
|---|---|---|
| committer | 2024-11-07 19:42:02 +0100 | |
| commit | 0f8ade8c6050d61d1a9bf0522ac087eaf41eab14 (patch) | |
| tree | 9eff0dbadcf4ca0807fe69f5a1f1ed8cdd20d3f9 | |
| parent | Also use the proxy in replace_shortnames(). (diff) | |
| download | penes-snac2-0f8ade8c6050d61d1a9bf0522ac087eaf41eab14.tar.gz penes-snac2-0f8ade8c6050d61d1a9bf0522ac087eaf41eab14.tar.xz penes-snac2-0f8ade8c6050d61d1a9bf0522ac087eaf41eab14.zip | |
Propagate 'last-modified' and 'etag' fields while proxying.
But does it work?
| -rw-r--r-- | html.c | 8 | ||||
| -rw-r--r-- | httpd.c | 5 | ||||
| -rw-r--r-- | snac.h | 4 |
3 files changed, 14 insertions, 3 deletions
| @@ -2796,7 +2796,8 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2796 | 2796 | ||
| 2797 | 2797 | ||
| 2798 | int html_get_handler(const xs_dict *req, const char *q_path, | 2798 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 2799 | char **body, int *b_size, char **ctype, xs_str **etag) | 2799 | char **body, int *b_size, char **ctype, |
| 2800 | xs_str **etag, xs_str **last_modified) | ||
| 2800 | { | 2801 | { |
| 2801 | const char *accept = xs_dict_get(req, "accept"); | 2802 | const char *accept = xs_dict_get(req, "accept"); |
| 2802 | int status = HTTP_STATUS_NOT_FOUND; | 2803 | int status = HTTP_STATUS_NOT_FOUND; |
| @@ -3227,6 +3228,11 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3227 | 3228 | ||
| 3228 | if (valid_status(status)) { | 3229 | if (valid_status(status)) { |
| 3229 | const char *ct = xs_dict_get(rsp, "content-type"); | 3230 | const char *ct = xs_dict_get(rsp, "content-type"); |
| 3231 | const char *lm = xs_dict_get(rsp, "last-modified"); | ||
| 3232 | const char *et = xs_dict_get(rsp, "etag"); | ||
| 3233 | |||
| 3234 | if (lm) *last_modified = xs_dup(lm); | ||
| 3235 | if (et) *etag = xs_dup(et); | ||
| 3230 | 3236 | ||
| 3231 | /* find the content-type in the static mime types, | 3237 | /* find the content-type in the static mime types, |
| 3232 | and return that value instead of ct, which will | 3238 | and return that value instead of ct, which will |
| @@ -278,6 +278,7 @@ void httpd_connection(FILE *f) | |||
| 278 | xs *q_path = NULL; | 278 | xs *q_path = NULL; |
| 279 | xs *payload = NULL; | 279 | xs *payload = NULL; |
| 280 | xs *etag = NULL; | 280 | xs *etag = NULL; |
| 281 | xs *last_modified = NULL; | ||
| 281 | int p_size = 0; | 282 | int p_size = 0; |
| 282 | const char *p; | 283 | const char *p; |
| 283 | int fcgi_id; | 284 | int fcgi_id; |
| @@ -329,7 +330,7 @@ void httpd_connection(FILE *f) | |||
| 329 | #endif /* NO_MASTODON_API */ | 330 | #endif /* NO_MASTODON_API */ |
| 330 | 331 | ||
| 331 | if (status == 0) | 332 | if (status == 0) |
| 332 | status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag); | 333 | status = html_get_handler(req, q_path, &body, &b_size, &ctype, &etag, &last_modified); |
| 333 | } | 334 | } |
| 334 | else | 335 | else |
| 335 | if (strcmp(method, "POST") == 0) { | 336 | if (strcmp(method, "POST") == 0) { |
| @@ -423,6 +424,8 @@ void httpd_connection(FILE *f) | |||
| 423 | 424 | ||
| 424 | if (!xs_is_null(etag)) | 425 | if (!xs_is_null(etag)) |
| 425 | headers = xs_dict_append(headers, "etag", etag); | 426 | headers = xs_dict_append(headers, "etag", etag); |
| 427 | if (!xs_is_null(last_modified)) | ||
| 428 | headers = xs_dict_append(headers, "last-modified", last_modified); | ||
| 426 | 429 | ||
| 427 | /* if there are any additional headers, add them */ | 430 | /* if there are any additional headers, add them */ |
| 428 | const xs_dict *more_headers = xs_dict_get(srv_config, "http_headers"); | 431 | const xs_dict *more_headers = xs_dict_get(srv_config, "http_headers"); |
| @@ -349,7 +349,9 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 349 | const char *title, const char *page, int utl, const char *error); | 349 | const char *title, const char *page, int utl, const char *error); |
| 350 | 350 | ||
| 351 | int html_get_handler(const xs_dict *req, const char *q_path, | 351 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 352 | char **body, int *b_size, char **ctype, xs_str **etag); | 352 | char **body, int *b_size, char **ctype, |
| 353 | xs_str **etag, xs_str **last_modified); | ||
| 354 | |||
| 353 | int html_post_handler(const xs_dict *req, const char *q_path, | 355 | int html_post_handler(const xs_dict *req, const char *q_path, |
| 354 | char *payload, int p_size, | 356 | char *payload, int p_size, |
| 355 | char **body, int *b_size, char **ctype); | 357 | char **body, int *b_size, char **ctype); |