From 2d433afc27afe46c9641cd0b0bd076566cfb67e2 Mon Sep 17 00:00:00 2001 From: Stefano Marinelli Date: Sat, 18 Oct 2025 21:33:31 +0200 Subject: 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 --- xs_httpd.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'xs_httpd.h') diff --git a/xs_httpd.h b/xs_httpd.h index 57759c4..0f03599 100644 --- a/xs_httpd.h +++ b/xs_httpd.h @@ -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"); -- cgit