summaryrefslogtreecommitdiff
path: root/xs_httpd.h
diff options
context:
space:
mode:
authorGravatar Stefano Marinelli2025-10-18 21:33:31 +0200
committerGravatar Stefano Marinelli2025-10-18 21:33:31 +0200
commit2d433afc27afe46c9641cd0b0bd076566cfb67e2 (patch)
tree826378411a16df79b16b5b351b7c56d20db3219f /xs_httpd.h
parentFEDERATION.md: also document outgoing Webmention. (diff)
downloadsnac2-2d433afc27afe46c9641cd0b0bd076566cfb67e2.tar.gz
snac2-2d433afc27afe46c9641cd0b0bd076566cfb67e2.tar.xz
snac2-2d433afc27afe46c9641cd0b0bd076566cfb67e2.zip
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.h28
1 files changed, 28 insertions, 0 deletions
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)
87 *p_size = atoi(v); 87 *p_size = atoi(v);
88 *payload = xs_read(f, p_size); 88 *payload = xs_read(f, p_size);
89 } 89 }
90 else if ((v = xs_dict_get(req, "transfer-encoding")) != NULL &&
91 xs_startswith(v, "chunked")) {
92 /* handle chunked transfer encoding */
93 xs_str *body = xs_str_new(NULL);
94
95 for (;;) {
96 xs *line = xs_strip_i(xs_readline(f));
97
98 /* parse chunk size (in hex) */
99 int chunk_size = strtol(line, NULL, 16);
100
101 if (chunk_size <= 0)
102 break;
103
104 /* read chunk data */
105 xs *chunk = xs_read(f, &chunk_size);
106 if (chunk == NULL)
107 break;
108
109 body = xs_append_m(body, chunk, chunk_size);
110
111 /* read trailing \r\n after chunk data */
112 xs_readline(f);
113 }
114
115 *p_size = xs_size(body) - 1; /* subtract trailing null */
116 *payload = body;
117 }
90 118
91 v = xs_dict_get(req, "content-type"); 119 v = xs_dict_get(req, "content-type");
92 120