diff options
| author | 2023-02-02 03:49:38 +0100 | |
|---|---|---|
| committer | 2023-02-02 03:49:38 +0100 | |
| commit | 463439283a3f346a8869df6d17a70f20a0a02419 (patch) | |
| tree | 8c9ec3c9c2552a8dab6ee55bceca9f5951ae8788 | |
| parent | Backport from xs. (diff) | |
| download | penes-snac2-463439283a3f346a8869df6d17a70f20a0a02419.tar.gz penes-snac2-463439283a3f346a8869df6d17a70f20a0a02419.tar.xz penes-snac2-463439283a3f346a8869df6d17a70f20a0a02419.zip | |
Minor header tweaks.
| -rw-r--r-- | http.c | 20 | ||||
| -rw-r--r-- | snac.c | 6 | ||||
| -rw-r--r-- | snac.h | 16 | ||||
| -rw-r--r-- | xs_curl.h | 14 |
4 files changed, 31 insertions, 25 deletions
| @@ -11,19 +11,19 @@ | |||
| 11 | 11 | ||
| 12 | #include "snac.h" | 12 | #include "snac.h" |
| 13 | 13 | ||
| 14 | d_char *http_signed_request(snac *snac, char *method, char *url, | 14 | xs_dict *http_signed_request(snac *snac, const char *method, const char *url, |
| 15 | d_char *headers, | 15 | xs_dict *headers, |
| 16 | d_char *body, int b_size, | 16 | const char *body, int b_size, |
| 17 | int *status, d_char **payload, int *p_size, | 17 | int *status, xs_str **payload, int *p_size, |
| 18 | int timeout) | 18 | int timeout) |
| 19 | /* does a signed HTTP request */ | 19 | /* does a signed HTTP request */ |
| 20 | { | 20 | { |
| 21 | xs *l1; | 21 | xs *l1 = NULL; |
| 22 | xs *date; | 22 | xs *date = NULL; |
| 23 | xs *digest; | 23 | xs *digest = NULL; |
| 24 | xs *s64; | 24 | xs *s64 = NULL; |
| 25 | xs *signature; | 25 | xs *signature = NULL; |
| 26 | xs *hdrs; | 26 | xs *hdrs = NULL; |
| 27 | char *host; | 27 | char *host; |
| 28 | char *target; | 28 | char *target; |
| 29 | char *seckey; | 29 | char *seckey; |
| @@ -138,8 +138,10 @@ int check_password(const char *uid, const char *passwd, const char *hash) | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | void srv_archive(char *direction, char *req, char *payload, int p_size, | 141 | void srv_archive(const char *direction, xs_dict *req, |
| 142 | int status, char *headers, char *body, int b_size) | 142 | const char *payload, int p_size, |
| 143 | int status, xs_dict *headers, | ||
| 144 | const char *body, int b_size) | ||
| 143 | /* archives a connection */ | 145 | /* archives a connection */ |
| 144 | { | 146 | { |
| 145 | /* obsessive archiving */ | 147 | /* obsessive archiving */ |
| @@ -46,8 +46,10 @@ int validate_uid(const char *uid); | |||
| 46 | d_char *hash_password(const char *uid, const char *passwd, const char *nonce); | 46 | d_char *hash_password(const char *uid, const char *passwd, const char *nonce); |
| 47 | int check_password(const char *uid, const char *passwd, const char *hash); | 47 | int check_password(const char *uid, const char *passwd, const char *hash); |
| 48 | 48 | ||
| 49 | void srv_archive(char *direction, char *req, char *payload, int p_size, | 49 | void srv_archive(const char *direction, xs_dict *req, |
| 50 | int status, char *headers, char *body, int b_size); | 50 | const char *payload, int p_size, |
| 51 | int status, xs_dict *headers, | ||
| 52 | const char *body, int b_size); | ||
| 51 | 53 | ||
| 52 | double mtime_nl(const char *fn, int *n_link); | 54 | double mtime_nl(const char *fn, int *n_link); |
| 53 | #define mtime(fn) mtime_nl(fn, NULL) | 55 | #define mtime(fn) mtime_nl(fn, NULL) |
| @@ -133,11 +135,11 @@ d_char *dequeue(snac *snac, char *fn); | |||
| 133 | void purge(snac *snac); | 135 | void purge(snac *snac); |
| 134 | void purge_all(void); | 136 | void purge_all(void); |
| 135 | 137 | ||
| 136 | d_char *http_signed_request(snac *snac, char *method, char *url, | 138 | xs_dict *http_signed_request(snac *snac, const char *method, const char *url, |
| 137 | d_char *headers, | 139 | xs_dict *headers, |
| 138 | d_char *body, int b_size, | 140 | const char *body, int b_size, |
| 139 | int *status, d_char **payload, int *p_size, | 141 | int *status, xs_str **payload, int *p_size, |
| 140 | int timeout); | 142 | int timeout); |
| 141 | int check_signature(snac *snac, char *req); | 143 | int check_signature(snac *snac, char *req); |
| 142 | 144 | ||
| 143 | void httpd(void); | 145 | void httpd(void); |
| @@ -4,8 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #define _XS_CURL_H | 5 | #define _XS_CURL_H |
| 6 | 6 | ||
| 7 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | 7 | xs_dict *xs_http_request(const char *method, const char *url, |
| 8 | xs_str *body, int b_size, int *status, | 8 | const xs_dict *headers, |
| 9 | const xs_str *body, int b_size, int *status, | ||
| 9 | xs_str **payload, int *p_size, int timeout); | 10 | xs_str **payload, int *p_size, int timeout); |
| 10 | 11 | ||
| 11 | #ifdef XS_IMPLEMENTATION | 12 | #ifdef XS_IMPLEMENTATION |
| @@ -83,8 +84,9 @@ static int _post_callback(char *buffer, size_t size, | |||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | 86 | ||
| 86 | xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | 87 | xs_dict *xs_http_request(const char *method, const char *url, |
| 87 | xs_str *body, int b_size, int *status, | 88 | const xs_dict *headers, |
| 89 | const xs_str *body, int b_size, int *status, | ||
| 88 | xs_str **payload, int *p_size, int timeout) | 90 | xs_str **payload, int *p_size, int timeout) |
| 89 | /* does an HTTP request */ | 91 | /* does an HTTP request */ |
| 90 | { | 92 | { |
| @@ -136,7 +138,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | |||
| 136 | sprintf(tmp, "content-length: %d", b_size); | 138 | sprintf(tmp, "content-length: %d", b_size); |
| 137 | list = curl_slist_append(list, tmp); | 139 | list = curl_slist_append(list, tmp); |
| 138 | 140 | ||
| 139 | pd.data = body; | 141 | pd.data = (char *)body; |
| 140 | pd.size = b_size; | 142 | pd.size = b_size; |
| 141 | pd.offset = 0; | 143 | pd.offset = 0; |
| 142 | 144 | ||
| @@ -146,7 +148,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, | |||
| 146 | } | 148 | } |
| 147 | 149 | ||
| 148 | /* fill the request headers */ | 150 | /* fill the request headers */ |
| 149 | p = headers; | 151 | p = (xs_dict *)headers; |
| 150 | while (xs_dict_iter(&p, &k, &v)) { | 152 | while (xs_dict_iter(&p, &k, &v)) { |
| 151 | xs *h = xs_fmt("%s: %s", k, v); | 153 | xs *h = xs_fmt("%s: %s", k, v); |
| 152 | 154 | ||