summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-23 17:40:59 +0200
committerdefault <nobody@localhost>2022-09-23 17:40:59 +0200
commit11134e58a3db29fd09497c20943d1ee7605623b1 (patch)
treedc5389126178d4a05066c562032a9dd8fe422ee5
parent40193b132007156bd5c44b576df1305ab2492771 (diff)
webfinger_get_handler() returns the status.
-rw-r--r--httpd.c2
-rw-r--r--snac.h4
-rw-r--r--webfinger.c26
3 files changed, 17 insertions, 15 deletions
diff --git a/httpd.c b/httpd.c
index bd3e44c..a56ce2a 100644
--- a/httpd.c
+++ b/httpd.c
@@ -126,7 +126,7 @@ void httpd_connection(int rs)
server_get_handler(req, q_path, &status, &body, &b_size, &ctype);
if (status == 0)
- webfinger_get_handler(req, q_path, &status, &body, &b_size, &ctype);
+ status = webfinger_get_handler(req, q_path, &body, &b_size, &ctype);
}
else
if (strcmp(method, "POST") == 0) {
diff --git a/snac.h b/snac.h
index b181e61..bb3db8b 100644
--- a/snac.h
+++ b/snac.h
@@ -77,7 +77,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
void httpd(void);
int webfinger_request(char *qs, char **actor, char **user);
-void webfinger_get_handler(d_char *req, char *q_path, int *status,
- char **body, int *b_size, char **ctype);
+int webfinger_get_handler(d_char *req, char *q_path,
+ char **body, int *b_size, char **ctype);
int activitypub_request(snac *snac, char *url, d_char **data);
diff --git a/webfinger.c b/webfinger.c
index 3fc1eab..e9f0893 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -58,8 +58,8 @@ int webfinger_request(char *qs, char **actor, char **user)
q_vars = xs_dict_append(q_vars, "resource", resource);
req = xs_dict_append(req, "q_vars", q_vars);
- webfinger_get_handler(req, "/.well-known/webfinger",
- &status, &payload, &p_size, &ctype);
+ status = webfinger_get_handler(req, "/.well-known/webfinger",
+ &payload, &p_size, &ctype);
}
else {
xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource);
@@ -98,20 +98,20 @@ int webfinger_request(char *qs, char **actor, char **user)
}
-void webfinger_get_handler(d_char *req, char *q_path, int *status,
+int webfinger_get_handler(d_char *req, char *q_path,
char **body, int *b_size, char **ctype)
/* serves webfinger queries */
{
+ int status;
+
if (strcmp(q_path, "/.well-known/webfinger") != 0)
- return;
+ return 0;
char *q_vars = xs_dict_get(req, "q_vars");
char *resource = xs_dict_get(q_vars, "resource");
- if (resource == NULL) {
- *status = 400;
- return;
- }
+ if (resource == NULL)
+ return 400;
snac snac;
int found = 0;
@@ -178,10 +178,12 @@ void webfinger_get_handler(d_char *req, char *q_path, int *status,
user_free(&snac);
- *status = 200;
- *body = j;
- *ctype = "application/json";
+ status = 200;
+ *body = j;
+ *ctype = "application/json";
}
else
- *status = 404;
+ status = 404;
+
+ return status;
}