diff --git a/http.c b/http.c index 2cbcdec..56fbbda 100644 --- a/http.c +++ b/http.c @@ -75,12 +75,12 @@ d_char *http_signed_request(snac *snac, char *method, char *url, /* add the new headers */ hdrs = xs_dict_append(hdrs, "content-type", "application/activity+json"); + hdrs = xs_dict_append(hdrs, "accept", "application/activity+json"); hdrs = xs_dict_append(hdrs, "date", date); hdrs = xs_dict_append(hdrs, "signature", signature); hdrs = xs_dict_append(hdrs, "digest", digest); hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x"); -// return xs_http_request(method, url, hdrs, -// body, b_size, status, payload, p_size); - return NULL; + return xs_http_request(method, url, hdrs, + body, b_size, status, payload, p_size); } diff --git a/main.c b/main.c index 5ae39c5..ec3dbf6 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,8 @@ /* copyright (c) 2022 grunfink - MIT license */ #include "xs.h" +#include "xs_encdec.h" +#include "xs_json.h" #include "snac.h" @@ -19,9 +21,17 @@ int main(int argc, char *argv[]) int status; d_char *payload; int p_size; - http_signed_request(&snac, "GET", "https://comam.es/snac/jessie", + xs *response; + + response = http_signed_request(&snac, "GET", "https://mastodon.social/users/VictorMoral", headers, NULL, 0, &status, &payload, &p_size); + { + xs *j1 = xs_json_dumps_pp(response, 4); + printf("response:\n%s\n", j1); + printf("payload:\n%s\n", payload); + } + { xs *list = queue(&snac); char *p, *fn; diff --git a/xs_curl.h b/xs_curl.h index 6309ea8..a1a1bcf 100644 --- a/xs_curl.h +++ b/xs_curl.h @@ -138,10 +138,7 @@ d_char *xs_http_request(char *method, char *url, d_char *headers, /* fill the request headers */ p = headers; while (xs_dict_iter(&p, &k, &v)) { - xs *h; - - const char *args[] = { k, v, NULL }; - h = xs_fmt("%s: %s", args); + xs *h = xs_fmt("%s: %s", k, v); list = curl_slist_append(list, h); }