mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-24 16:43:36 +00:00
More work in http signed request.
This commit is contained in:
parent
9573dbcdb6
commit
d2bdaf378f
3 changed files with 15 additions and 8 deletions
6
http.c
6
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);
|
||||
}
|
||||
|
|
12
main.c
12
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue