diff options
| author | Stefano Marinelli <stefano@dragas.it> | 2025-10-18 21:33:31 +0200 |
|---|---|---|
| committer | Stefano Marinelli <stefano@dragas.it> | 2025-10-18 21:33:31 +0200 |
| commit | 2d433afc27afe46c9641cd0b0bd076566cfb67e2 (patch) | |
| tree | 826378411a16df79b16b5b351b7c56d20db3219f /xs_httpd.h | |
| parent | 0fd993d5c6e3567c41b8ab6147f5490990fc5284 (diff) | |
Enhances Mastodon API compatibility by adding support for displaying remote users' follower/following/post counts and their posts when viewing profiles in Mastodon-compatible apps (Fedilab, Tusky, etc.).
Fixes for Moshidon and improvements for better compatibility with HAProxy
Diffstat (limited to 'xs_httpd.h')
| -rw-r--r-- | xs_httpd.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -87,6 +87,34 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size) *p_size = atoi(v); *payload = xs_read(f, p_size); } + else if ((v = xs_dict_get(req, "transfer-encoding")) != NULL && + xs_startswith(v, "chunked")) { + /* handle chunked transfer encoding */ + xs_str *body = xs_str_new(NULL); + + for (;;) { + xs *line = xs_strip_i(xs_readline(f)); + + /* parse chunk size (in hex) */ + int chunk_size = strtol(line, NULL, 16); + + if (chunk_size <= 0) + break; + + /* read chunk data */ + xs *chunk = xs_read(f, &chunk_size); + if (chunk == NULL) + break; + + body = xs_append_m(body, chunk, chunk_size); + + /* read trailing \r\n after chunk data */ + xs_readline(f); + } + + *p_size = xs_size(body) - 1; /* subtract trailing null */ + *payload = body; + } v = xs_dict_get(req, "content-type"); |