mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
webfinger_get_handler() returns the status.
This commit is contained in:
parent
40193b1320
commit
11134e58a3
3 changed files with 17 additions and 15 deletions
2
httpd.c
2
httpd.c
|
@ -126,7 +126,7 @@ void httpd_connection(int rs)
|
||||||
server_get_handler(req, q_path, &status, &body, &b_size, &ctype);
|
server_get_handler(req, q_path, &status, &body, &b_size, &ctype);
|
||||||
|
|
||||||
if (status == 0)
|
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
|
else
|
||||||
if (strcmp(method, "POST") == 0) {
|
if (strcmp(method, "POST") == 0) {
|
||||||
|
|
4
snac.h
4
snac.h
|
@ -77,7 +77,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
void httpd(void);
|
void httpd(void);
|
||||||
|
|
||||||
int webfinger_request(char *qs, char **actor, char **user);
|
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);
|
char **body, int *b_size, char **ctype);
|
||||||
|
|
||||||
int activitypub_request(snac *snac, char *url, d_char **data);
|
int activitypub_request(snac *snac, char *url, d_char **data);
|
||||||
|
|
26
webfinger.c
26
webfinger.c
|
@ -58,8 +58,8 @@ int webfinger_request(char *qs, char **actor, char **user)
|
||||||
q_vars = xs_dict_append(q_vars, "resource", resource);
|
q_vars = xs_dict_append(q_vars, "resource", resource);
|
||||||
req = xs_dict_append(req, "q_vars", q_vars);
|
req = xs_dict_append(req, "q_vars", q_vars);
|
||||||
|
|
||||||
webfinger_get_handler(req, "/.well-known/webfinger",
|
status = webfinger_get_handler(req, "/.well-known/webfinger",
|
||||||
&status, &payload, &p_size, &ctype);
|
&payload, &p_size, &ctype);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource);
|
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)
|
char **body, int *b_size, char **ctype)
|
||||||
/* serves webfinger queries */
|
/* serves webfinger queries */
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
if (strcmp(q_path, "/.well-known/webfinger") != 0)
|
if (strcmp(q_path, "/.well-known/webfinger") != 0)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
char *q_vars = xs_dict_get(req, "q_vars");
|
char *q_vars = xs_dict_get(req, "q_vars");
|
||||||
char *resource = xs_dict_get(q_vars, "resource");
|
char *resource = xs_dict_get(q_vars, "resource");
|
||||||
|
|
||||||
if (resource == NULL) {
|
if (resource == NULL)
|
||||||
*status = 400;
|
return 400;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
snac snac;
|
snac snac;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
@ -178,10 +178,12 @@ void webfinger_get_handler(d_char *req, char *q_path, int *status,
|
||||||
|
|
||||||
user_free(&snac);
|
user_free(&snac);
|
||||||
|
|
||||||
*status = 200;
|
status = 200;
|
||||||
*body = j;
|
*body = j;
|
||||||
*ctype = "application/json";
|
*ctype = "application/json";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*status = 404;
|
status = 404;
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue