Minor header tweaks.

This commit is contained in:
default 2023-02-02 03:49:38 +01:00
parent ec07b0c59d
commit 463439283a
4 changed files with 31 additions and 25 deletions

20
http.c
View file

@ -11,19 +11,19 @@
#include "snac.h"
d_char *http_signed_request(snac *snac, char *method, char *url,
d_char *headers,
d_char *body, int b_size,
int *status, d_char **payload, int *p_size,
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
xs_dict *headers,
const char *body, int b_size,
int *status, xs_str **payload, int *p_size,
int timeout)
/* does a signed HTTP request */
{
xs *l1;
xs *date;
xs *digest;
xs *s64;
xs *signature;
xs *hdrs;
xs *l1 = NULL;
xs *date = NULL;
xs *digest = NULL;
xs *s64 = NULL;
xs *signature = NULL;
xs *hdrs = NULL;
char *host;
char *target;
char *seckey;

6
snac.c
View file

@ -138,8 +138,10 @@ int check_password(const char *uid, const char *passwd, const char *hash)
}
void srv_archive(char *direction, char *req, char *payload, int p_size,
int status, char *headers, char *body, int b_size)
void srv_archive(const char *direction, xs_dict *req,
const char *payload, int p_size,
int status, xs_dict *headers,
const char *body, int b_size)
/* archives a connection */
{
/* obsessive archiving */

16
snac.h
View file

@ -46,8 +46,10 @@ int validate_uid(const char *uid);
d_char *hash_password(const char *uid, const char *passwd, const char *nonce);
int check_password(const char *uid, const char *passwd, const char *hash);
void srv_archive(char *direction, char *req, char *payload, int p_size,
int status, char *headers, char *body, int b_size);
void srv_archive(const char *direction, xs_dict *req,
const char *payload, int p_size,
int status, xs_dict *headers,
const char *body, int b_size);
double mtime_nl(const char *fn, int *n_link);
#define mtime(fn) mtime_nl(fn, NULL)
@ -133,11 +135,11 @@ d_char *dequeue(snac *snac, char *fn);
void purge(snac *snac);
void purge_all(void);
d_char *http_signed_request(snac *snac, char *method, char *url,
d_char *headers,
d_char *body, int b_size,
int *status, d_char **payload, int *p_size,
int timeout);
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
xs_dict *headers,
const char *body, int b_size,
int *status, xs_str **payload, int *p_size,
int timeout);
int check_signature(snac *snac, char *req);
void httpd(void);

View file

@ -4,8 +4,9 @@
#define _XS_CURL_H
xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
xs_str *body, int b_size, int *status,
xs_dict *xs_http_request(const char *method, const char *url,
const xs_dict *headers,
const xs_str *body, int b_size, int *status,
xs_str **payload, int *p_size, int timeout);
#ifdef XS_IMPLEMENTATION
@ -83,8 +84,9 @@ static int _post_callback(char *buffer, size_t size,
}
xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
xs_str *body, int b_size, int *status,
xs_dict *xs_http_request(const char *method, const char *url,
const xs_dict *headers,
const xs_str *body, int b_size, int *status,
xs_str **payload, int *p_size, int timeout)
/* does an HTTP request */
{
@ -136,7 +138,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
sprintf(tmp, "content-length: %d", b_size);
list = curl_slist_append(list, tmp);
pd.data = body;
pd.data = (char *)body;
pd.size = b_size;
pd.offset = 0;
@ -146,7 +148,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
}
/* fill the request headers */
p = headers;
p = (xs_dict *)headers;
while (xs_dict_iter(&p, &k, &v)) {
xs *h = xs_fmt("%s: %s", k, v);