mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Use its own copy of the headers in http_signed_request().
This commit is contained in:
parent
d76131b473
commit
8dadbbc78e
2 changed files with 15 additions and 8 deletions
21
http.c
21
http.c
|
@ -20,9 +20,11 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
xs *digest;
|
xs *digest;
|
||||||
xs *s64;
|
xs *s64;
|
||||||
xs *signature;
|
xs *signature;
|
||||||
|
xs *hdrs;
|
||||||
char *host;
|
char *host;
|
||||||
char *target;
|
char *target;
|
||||||
char *seckey;
|
char *seckey;
|
||||||
|
char *k, *v;
|
||||||
|
|
||||||
date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT");
|
date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT");
|
||||||
|
|
||||||
|
@ -66,14 +68,19 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
"signature=\"%s\"",
|
"signature=\"%s\"",
|
||||||
snac->actor, s64);
|
snac->actor, s64);
|
||||||
|
|
||||||
/* now add all these things to the headers */
|
/* transfer the original headers */
|
||||||
headers = xs_dict_append(headers, "content-type", "application/activity+json");
|
hdrs = xs_dict_new();
|
||||||
headers = xs_dict_append(headers, "date", date);
|
while (xs_dict_iter(&headers, &k, &v))
|
||||||
headers = xs_dict_append(headers, "signature", signature);
|
hdrs = xs_dict_append(hdrs, k, v);
|
||||||
headers = xs_dict_append(headers, "digest", digest);
|
|
||||||
headers = xs_dict_append(headers, "user-agent", "snac/2.x");
|
|
||||||
|
|
||||||
// return xs_http_request(method, url, headers,
|
/* add the new headers */
|
||||||
|
hdrs = xs_dict_append(hdrs, "content-type", "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);
|
// body, b_size, status, payload, p_size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
2
main.c
2
main.c
|
@ -15,7 +15,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
user_open(&snac, "mike");
|
user_open(&snac, "mike");
|
||||||
|
|
||||||
d_char *headers = xs_dict_new();
|
xs *headers = xs_dict_new();
|
||||||
int status;
|
int status;
|
||||||
d_char *payload;
|
d_char *payload;
|
||||||
int p_size;
|
int p_size;
|
||||||
|
|
Loading…
Reference in a new issue