mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
More work in http signed request.
This commit is contained in:
parent
9573dbcdb6
commit
d2bdaf378f
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 */
|
/* add the new headers */
|
||||||
hdrs = xs_dict_append(hdrs, "content-type", "application/activity+json");
|
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, "date", date);
|
||||||
hdrs = xs_dict_append(hdrs, "signature", signature);
|
hdrs = xs_dict_append(hdrs, "signature", signature);
|
||||||
hdrs = xs_dict_append(hdrs, "digest", digest);
|
hdrs = xs_dict_append(hdrs, "digest", digest);
|
||||||
hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x");
|
hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x");
|
||||||
|
|
||||||
// return xs_http_request(method, url, hdrs,
|
return xs_http_request(method, url, hdrs,
|
||||||
// body, b_size, status, payload, p_size);
|
body, b_size, status, payload, p_size);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
12
main.c
12
main.c
@ -2,6 +2,8 @@
|
|||||||
/* copyright (c) 2022 grunfink - MIT license */
|
/* copyright (c) 2022 grunfink - MIT license */
|
||||||
|
|
||||||
#include "xs.h"
|
#include "xs.h"
|
||||||
|
#include "xs_encdec.h"
|
||||||
|
#include "xs_json.h"
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
@ -19,9 +21,17 @@ int main(int argc, char *argv[])
|
|||||||
int status;
|
int status;
|
||||||
d_char *payload;
|
d_char *payload;
|
||||||
int p_size;
|
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);
|
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);
|
xs *list = queue(&snac);
|
||||||
char *p, *fn;
|
char *p, *fn;
|
||||||
|
@ -138,10 +138,7 @@ d_char *xs_http_request(char *method, char *url, d_char *headers,
|
|||||||
/* fill the request headers */
|
/* fill the request headers */
|
||||||
p = headers;
|
p = headers;
|
||||||
while (xs_dict_iter(&p, &k, &v)) {
|
while (xs_dict_iter(&p, &k, &v)) {
|
||||||
xs *h;
|
xs *h = xs_fmt("%s: %s", k, v);
|
||||||
|
|
||||||
const char *args[] = { k, v, NULL };
|
|
||||||
h = xs_fmt("%s: %s", args);
|
|
||||||
|
|
||||||
list = curl_slist_append(list, h);
|
list = curl_slist_append(list, h);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user