mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Minor header tweaks.
This commit is contained in:
parent
ec07b0c59d
commit
463439283a
4 changed files with 31 additions and 25 deletions
20
http.c
20
http.c
|
@ -11,19 +11,19 @@
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
d_char *http_signed_request(snac *snac, char *method, char *url,
|
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
|
||||||
d_char *headers,
|
xs_dict *headers,
|
||||||
d_char *body, int b_size,
|
const char *body, int b_size,
|
||||||
int *status, d_char **payload, int *p_size,
|
int *status, xs_str **payload, int *p_size,
|
||||||
int timeout)
|
int timeout)
|
||||||
/* does a signed HTTP request */
|
/* does a signed HTTP request */
|
||||||
{
|
{
|
||||||
xs *l1;
|
xs *l1 = NULL;
|
||||||
xs *date;
|
xs *date = NULL;
|
||||||
xs *digest;
|
xs *digest = NULL;
|
||||||
xs *s64;
|
xs *s64 = NULL;
|
||||||
xs *signature;
|
xs *signature = NULL;
|
||||||
xs *hdrs;
|
xs *hdrs = NULL;
|
||||||
char *host;
|
char *host;
|
||||||
char *target;
|
char *target;
|
||||||
char *seckey;
|
char *seckey;
|
||||||
|
|
6
snac.c
6
snac.c
|
@ -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,
|
void srv_archive(const char *direction, xs_dict *req,
|
||||||
int status, char *headers, char *body, int b_size)
|
const char *payload, int p_size,
|
||||||
|
int status, xs_dict *headers,
|
||||||
|
const char *body, int b_size)
|
||||||
/* archives a connection */
|
/* archives a connection */
|
||||||
{
|
{
|
||||||
/* obsessive archiving */
|
/* obsessive archiving */
|
||||||
|
|
14
snac.h
14
snac.h
|
@ -46,8 +46,10 @@ int validate_uid(const char *uid);
|
||||||
d_char *hash_password(const char *uid, const char *passwd, const char *nonce);
|
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);
|
int check_password(const char *uid, const char *passwd, const char *hash);
|
||||||
|
|
||||||
void srv_archive(char *direction, char *req, char *payload, int p_size,
|
void srv_archive(const char *direction, xs_dict *req,
|
||||||
int status, char *headers, char *body, int b_size);
|
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);
|
double mtime_nl(const char *fn, int *n_link);
|
||||||
#define mtime(fn) mtime_nl(fn, NULL)
|
#define mtime(fn) mtime_nl(fn, NULL)
|
||||||
|
@ -133,10 +135,10 @@ d_char *dequeue(snac *snac, char *fn);
|
||||||
void purge(snac *snac);
|
void purge(snac *snac);
|
||||||
void purge_all(void);
|
void purge_all(void);
|
||||||
|
|
||||||
d_char *http_signed_request(snac *snac, char *method, char *url,
|
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
|
||||||
d_char *headers,
|
xs_dict *headers,
|
||||||
d_char *body, int b_size,
|
const char *body, int b_size,
|
||||||
int *status, d_char **payload, int *p_size,
|
int *status, xs_str **payload, int *p_size,
|
||||||
int timeout);
|
int timeout);
|
||||||
int check_signature(snac *snac, char *req);
|
int check_signature(snac *snac, char *req);
|
||||||
|
|
||||||
|
|
14
xs_curl.h
14
xs_curl.h
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
#define _XS_CURL_H
|
#define _XS_CURL_H
|
||||||
|
|
||||||
xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
|
xs_dict *xs_http_request(const char *method, const char *url,
|
||||||
xs_str *body, int b_size, int *status,
|
const xs_dict *headers,
|
||||||
|
const xs_str *body, int b_size, int *status,
|
||||||
xs_str **payload, int *p_size, int timeout);
|
xs_str **payload, int *p_size, int timeout);
|
||||||
|
|
||||||
#ifdef XS_IMPLEMENTATION
|
#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_dict *xs_http_request(const char *method, const char *url,
|
||||||
xs_str *body, int b_size, int *status,
|
const xs_dict *headers,
|
||||||
|
const xs_str *body, int b_size, int *status,
|
||||||
xs_str **payload, int *p_size, int timeout)
|
xs_str **payload, int *p_size, int timeout)
|
||||||
/* does an HTTP request */
|
/* 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);
|
sprintf(tmp, "content-length: %d", b_size);
|
||||||
list = curl_slist_append(list, tmp);
|
list = curl_slist_append(list, tmp);
|
||||||
|
|
||||||
pd.data = body;
|
pd.data = (char *)body;
|
||||||
pd.size = b_size;
|
pd.size = b_size;
|
||||||
pd.offset = 0;
|
pd.offset = 0;
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ xs_dict *xs_http_request(char *method, char *url, xs_dict *headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill the request headers */
|
/* fill the request headers */
|
||||||
p = headers;
|
p = (xs_dict *)headers;
|
||||||
while (xs_dict_iter(&p, &k, &v)) {
|
while (xs_dict_iter(&p, &k, &v)) {
|
||||||
xs *h = xs_fmt("%s: %s", k, v);
|
xs *h = xs_fmt("%s: %s", k, v);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue