summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http.c20
-rw-r--r--snac.c6
-rw-r--r--snac.h16
-rw-r--r--xs_curl.h14
4 files changed, 31 insertions, 25 deletions
diff --git a/http.c b/http.c
index 881a7e0..1948f2b 100644
--- a/http.c
+++ b/http.c
@@ -11,19 +11,19 @@
11 11
12#include "snac.h" 12#include "snac.h"
13 13
14d_char *http_signed_request(snac *snac, char *method, char *url, 14xs_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;
diff --git a/snac.c b/snac.c
index e8c3a3d..c15a74a 100644
--- a/snac.c
+++ b/snac.c
@@ -138,8 +138,10 @@ int check_password(const char *uid, const char *passwd, const char *hash)
138} 138}
139 139
140 140
141void srv_archive(char *direction, char *req, char *payload, int p_size, 141void 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 */
diff --git a/snac.h b/snac.h
index dc6662e..6185e8b 100644
--- a/snac.h
+++ b/snac.h
@@ -46,8 +46,10 @@ int validate_uid(const char *uid);
46d_char *hash_password(const char *uid, const char *passwd, const char *nonce); 46d_char *hash_password(const char *uid, const char *passwd, const char *nonce);
47int check_password(const char *uid, const char *passwd, const char *hash); 47int check_password(const char *uid, const char *passwd, const char *hash);
48 48
49void srv_archive(char *direction, char *req, char *payload, int p_size, 49void 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
52double mtime_nl(const char *fn, int *n_link); 54double 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);
133void purge(snac *snac); 135void purge(snac *snac);
134void purge_all(void); 136void purge_all(void);
135 137
136d_char *http_signed_request(snac *snac, char *method, char *url, 138xs_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);
141int check_signature(snac *snac, char *req); 143int check_signature(snac *snac, char *req);
142 144
143void httpd(void); 145void httpd(void);
diff --git a/xs_curl.h b/xs_curl.h
index 2637c02..1ac0e13 100644
--- a/xs_curl.h
+++ b/xs_curl.h
@@ -4,8 +4,9 @@
4 4
5#define _XS_CURL_H 5#define _XS_CURL_H
6 6
7xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, 7xs_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
86xs_dict *xs_http_request(char *method, char *url, xs_dict *headers, 87xs_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