summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c26
1 files changed, 14 insertions, 12 deletions
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)
58 q_vars = xs_dict_append(q_vars, "resource", resource); 58 q_vars = xs_dict_append(q_vars, "resource", resource);
59 req = xs_dict_append(req, "q_vars", q_vars); 59 req = xs_dict_append(req, "q_vars", q_vars);
60 60
61 webfinger_get_handler(req, "/.well-known/webfinger", 61 status = webfinger_get_handler(req, "/.well-known/webfinger",
62 &status, &payload, &p_size, &ctype); 62 &payload, &p_size, &ctype);
63 } 63 }
64 else { 64 else {
65 xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource); 65 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)
98} 98}
99 99
100 100
101void webfinger_get_handler(d_char *req, char *q_path, int *status, 101int webfinger_get_handler(d_char *req, char *q_path,
102 char **body, int *b_size, char **ctype) 102 char **body, int *b_size, char **ctype)
103/* serves webfinger queries */ 103/* serves webfinger queries */
104{ 104{
105 int status;
106
105 if (strcmp(q_path, "/.well-known/webfinger") != 0) 107 if (strcmp(q_path, "/.well-known/webfinger") != 0)
106 return; 108 return 0;
107 109
108 char *q_vars = xs_dict_get(req, "q_vars"); 110 char *q_vars = xs_dict_get(req, "q_vars");
109 char *resource = xs_dict_get(q_vars, "resource"); 111 char *resource = xs_dict_get(q_vars, "resource");
110 112
111 if (resource == NULL) { 113 if (resource == NULL)
112 *status = 400; 114 return 400;
113 return;
114 }
115 115
116 snac snac; 116 snac snac;
117 int found = 0; 117 int found = 0;
@@ -178,10 +178,12 @@ void webfinger_get_handler(d_char *req, char *q_path, int *status,
178 178
179 user_free(&snac); 179 user_free(&snac);
180 180
181 *status = 200; 181 status = 200;
182 *body = j; 182 *body = j;
183 *ctype = "application/json"; 183 *ctype = "application/json";
184 } 184 }
185 else 185 else
186 *status = 404; 186 status = 404;
187
188 return status;
187} 189}