diff options
| author | 2022-09-21 08:57:02 +0200 | |
|---|---|---|
| committer | 2022-09-21 08:57:02 +0200 | |
| commit | 8dadbbc78ee71e1a60d263b902759d53fc297e7e (patch) | |
| tree | a96c3786fc9e6fd5daa36bf453e2c495ae90578b /http.c | |
| parent | Added http signed request code (untested). (diff) | |
| download | penes-snac2-8dadbbc78ee71e1a60d263b902759d53fc297e7e.tar.gz penes-snac2-8dadbbc78ee71e1a60d263b902759d53fc297e7e.tar.xz penes-snac2-8dadbbc78ee71e1a60d263b902759d53fc297e7e.zip | |
Use its own copy of the headers in http_signed_request().
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 21 |
1 files changed, 14 insertions, 7 deletions
| @@ -20,9 +20,11 @@ d_char *http_signed_request(snac *snac, char *method, char *url, | |||
| 20 | xs *digest; | 20 | xs *digest; |
| 21 | xs *s64; | 21 | xs *s64; |
| 22 | xs *signature; | 22 | xs *signature; |
| 23 | xs *hdrs; | ||
| 23 | char *host; | 24 | char *host; |
| 24 | char *target; | 25 | char *target; |
| 25 | char *seckey; | 26 | char *seckey; |
| 27 | char *k, *v; | ||
| 26 | 28 | ||
| 27 | date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT"); | 29 | date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT"); |
| 28 | 30 | ||
| @@ -66,14 +68,19 @@ d_char *http_signed_request(snac *snac, char *method, char *url, | |||
| 66 | "signature=\"%s\"", | 68 | "signature=\"%s\"", |
| 67 | snac->actor, s64); | 69 | snac->actor, s64); |
| 68 | 70 | ||
| 69 | /* now add all these things to the headers */ | 71 | /* transfer the original headers */ |
| 70 | headers = xs_dict_append(headers, "content-type", "application/activity+json"); | 72 | hdrs = xs_dict_new(); |
| 71 | headers = xs_dict_append(headers, "date", date); | 73 | while (xs_dict_iter(&headers, &k, &v)) |
| 72 | headers = xs_dict_append(headers, "signature", signature); | 74 | hdrs = xs_dict_append(hdrs, k, v); |
| 73 | headers = xs_dict_append(headers, "digest", digest); | ||
| 74 | headers = xs_dict_append(headers, "user-agent", "snac/2.x"); | ||
| 75 | 75 | ||
| 76 | // return xs_http_request(method, url, headers, | 76 | /* add the new headers */ |
| 77 | hdrs = xs_dict_append(hdrs, "content-type", "application/activity+json"); | ||
| 78 | hdrs = xs_dict_append(hdrs, "date", date); | ||
| 79 | hdrs = xs_dict_append(hdrs, "signature", signature); | ||
| 80 | hdrs = xs_dict_append(hdrs, "digest", digest); | ||
| 81 | hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x"); | ||
| 82 | |||
| 83 | // return xs_http_request(method, url, hdrs, | ||
| 77 | // body, b_size, status, payload, p_size); | 84 | // body, b_size, status, payload, p_size); |
| 78 | return NULL; | 85 | return NULL; |
| 79 | } | 86 | } |