summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorGravatar default2024-05-21 14:12:15 +0200
committerGravatar default2024-05-21 14:12:15 +0200
commit4777fc86cb962917a8f34afb3bfa40f26290815d (patch)
tree268c078531a018f07c1b6d029f14f87134805f7b /http.c
parentVersion 2.53 RELEASED. (diff)
downloadpenes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.gz
penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.xz
penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.zip
Added const everywhere.
Diffstat (limited to 'http.c')
-rw-r--r--http.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/http.c b/http.c
index f7ff9ba..4d85631 100644
--- a/http.c
+++ b/http.c
@@ -12,7 +12,7 @@
12 12
13xs_dict *http_signed_request_raw(const char *keyid, const char *seckey, 13xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
14 const char *method, const char *url, 14 const char *method, const char *url,
15 xs_dict *headers, 15 const xs_dict *headers,
16 const char *body, int b_size, 16 const char *body, int b_size,
17 int *status, xs_str **payload, int *p_size, 17 int *status, xs_str **payload, int *p_size,
18 int timeout) 18 int timeout)
@@ -24,8 +24,8 @@ xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
24 xs *s64 = NULL; 24 xs *s64 = NULL;
25 xs *signature = NULL; 25 xs *signature = NULL;
26 xs *hdrs = NULL; 26 xs *hdrs = NULL;
27 char *host; 27 const char *host;
28 char *target; 28 const char *target;
29 char *k, *v; 29 char *k, *v;
30 xs_dict *response; 30 xs_dict *response;
31 31
@@ -106,13 +106,13 @@ xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
106 106
107 107
108xs_dict *http_signed_request(snac *snac, const char *method, const char *url, 108xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
109 xs_dict *headers, 109 const xs_dict *headers,
110 const char *body, int b_size, 110 const char *body, int b_size,
111 int *status, xs_str **payload, int *p_size, 111 int *status, xs_str **payload, int *p_size,
112 int timeout) 112 int timeout)
113/* does a signed HTTP request */ 113/* does a signed HTTP request */
114{ 114{
115 char *seckey = xs_dict_get(snac->key, "secret"); 115 const char *seckey = xs_dict_get(snac->key, "secret");
116 xs_dict *response; 116 xs_dict *response;
117 117
118 response = http_signed_request_raw(snac->actor, seckey, method, url, 118 response = http_signed_request_raw(snac->actor, seckey, method, url,
@@ -122,17 +122,18 @@ xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
122} 122}
123 123
124 124
125int check_signature(xs_dict *req, xs_str **err) 125int check_signature(const xs_dict *req, xs_str **err)
126/* check the signature */ 126/* check the signature */
127{ 127{
128 char *sig_hdr = xs_dict_get(req, "signature"); 128 const char *sig_hdr = xs_dict_get(req, "signature");
129 xs *keyId = NULL; 129 xs *keyId = NULL;
130 xs *headers = NULL; 130 xs *headers = NULL;
131 xs *signature = NULL; 131 xs *signature = NULL;
132 xs *created = NULL; 132 xs *created = NULL;
133 xs *expires = NULL; 133 xs *expires = NULL;
134 char *pubkey;
135 char *p; 134 char *p;
135 const char *pubkey;
136 const char *k;
136 137
137 if (xs_is_null(sig_hdr)) { 138 if (xs_is_null(sig_hdr)) {
138 *err = xs_fmt("missing 'signature' header"); 139 *err = xs_fmt("missing 'signature' header");
@@ -142,10 +143,10 @@ int check_signature(xs_dict *req, xs_str **err)
142 { 143 {
143 /* extract the values */ 144 /* extract the values */
144 xs *l = xs_split(sig_hdr, ","); 145 xs *l = xs_split(sig_hdr, ",");
145 xs_list *p = l; 146 int c = 0;
146 xs_val *v; 147 xs_val *v;
147 148
148 while (xs_list_iter(&p, &v)) { 149 while (xs_list_next(l, &v, &c)) {
149 xs *kv = xs_split_n(v, "=", 1); 150 xs *kv = xs_split_n(v, "=", 1);
150 151
151 if (xs_list_len(kv) != 2) 152 if (xs_list_len(kv) != 2)
@@ -192,8 +193,8 @@ int check_signature(xs_dict *req, xs_str **err)
192 return 0; 193 return 0;
193 } 194 }
194 195
195 if ((p = xs_dict_get(actor, "publicKey")) == NULL || 196 if ((k = xs_dict_get(actor, "publicKey")) == NULL ||
196 ((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) { 197 ((pubkey = xs_dict_get(k, "publicKeyPem")) == NULL)) {
197 *err = xs_fmt("cannot get pubkey from %s", keyId); 198 *err = xs_fmt("cannot get pubkey from %s", keyId);
198 return 0; 199 return 0;
199 } 200 }
@@ -208,7 +209,7 @@ int check_signature(xs_dict *req, xs_str **err)
208 209
209 p = l; 210 p = l;
210 while (xs_list_iter(&p, &v)) { 211 while (xs_list_iter(&p, &v)) {
211 char *hc; 212 const char *hc;
212 xs *ss = NULL; 213 xs *ss = NULL;
213 214
214 if (*sig_str != '\0') 215 if (*sig_str != '\0')