diff options
| author | 2025-10-21 13:54:45 +0200 | |
|---|---|---|
| committer | 2025-10-21 13:54:45 +0200 | |
| commit | ee875579a649fb51def31949b5ff1ad012fa20c9 (patch) | |
| tree | 9b7c90f92bf89a3474eaacb3bcc0e5ec1fbd4b65 /xs_httpd.h | |
| parent | FEDERATION.md: also document outgoing Webmention. (diff) | |
| parent | Instead of comparing the output status with == 200, it's better to check usin... (diff) | |
| download | snac2-ee875579a649fb51def31949b5ff1ad012fa20c9.tar.gz snac2-ee875579a649fb51def31949b5ff1ad012fa20c9.tar.xz snac2-ee875579a649fb51def31949b5ff1ad012fa20c9.zip | |
Merge pull request 'Improving Mastodon-api experience and Moshidon support' (#489) from draga79/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/489
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) | |||
| 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 | ||