aboutsummaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-21 08:57:02 +0200
committerdefault <nobody@localhost>2022-09-21 08:57:02 +0200
commit8dadbbc78ee71e1a60d263b902759d53fc297e7e (patch)
treea96c3786fc9e6fd5daa36bf453e2c495ae90578b /http.c
parentd76131b4737832585e58bda6e47125d8fb9bd8b4 (diff)
Use its own copy of the headers in http_signed_request().
Diffstat (limited to 'http.c')
-rw-r--r--http.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/http.c b/http.c
index 6f435cb..88222a5 100644
--- a/http.c
+++ b/http.c
@@ -20,9 +20,11 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
xs *digest;
xs *s64;
xs *signature;
+ xs *hdrs;
char *host;
char *target;
char *seckey;
+ char *k, *v;
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\"",
snac->actor, s64);
- /* now add all these things to the headers */
- headers = xs_dict_append(headers, "content-type", "application/activity+json");
- headers = xs_dict_append(headers, "date", date);
- headers = xs_dict_append(headers, "signature", signature);
- headers = xs_dict_append(headers, "digest", digest);
- headers = xs_dict_append(headers, "user-agent", "snac/2.x");
+ /* transfer the original headers */
+ hdrs = xs_dict_new();
+ while (xs_dict_iter(&headers, &k, &v))
+ hdrs = xs_dict_append(hdrs, k, v);
-// 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);
return NULL;
}