summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--webfinger.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/webfinger.c b/webfinger.c
index 519fb67..3fc1eab 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -8,9 +8,10 @@
8 8
9#include "snac.h" 9#include "snac.h"
10 10
11void webfinger_request(char *qs, int *status, char **actor, char **user) 11int webfinger_request(char *qs, char **actor, char **user)
12/* queries the webfinger for qs and fills the required fields */ 12/* queries the webfinger for qs and fills the required fields */
13{ 13{
14 int status;
14 xs *payload = NULL; 15 xs *payload = NULL;
15 int p_size = 0; 16 int p_size = 0;
16 xs *headers = xs_dict_new(); 17 xs *headers = xs_dict_new();
@@ -42,10 +43,8 @@ void webfinger_request(char *qs, int *status, char **actor, char **user)
42 } 43 }
43 } 44 }
44 45
45 if (host == NULL || resource == NULL) { 46 if (host == NULL || resource == NULL)
46 *status = 400; 47 return 400;
47 return;
48 }
49 48
50 headers = xs_dict_append(headers, "accept", "application/json"); 49 headers = xs_dict_append(headers, "accept", "application/json");
51 50
@@ -60,15 +59,15 @@ void webfinger_request(char *qs, int *status, char **actor, char **user)
60 req = xs_dict_append(req, "q_vars", q_vars); 59 req = xs_dict_append(req, "q_vars", q_vars);
61 60
62 webfinger_get_handler(req, "/.well-known/webfinger", 61 webfinger_get_handler(req, "/.well-known/webfinger",
63 status, &payload, &p_size, &ctype); 62 &status, &payload, &p_size, &ctype);
64 } 63 }
65 else { 64 else {
66 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);
67 66
68 xs_http_request("GET", url, headers, NULL, 0, status, &payload, &p_size); 67 xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size);
69 } 68 }
70 69
71 if (valid_status(*status)) { 70 if (valid_status(status)) {
72 xs *obj = xs_json_loads(payload); 71 xs *obj = xs_json_loads(payload);
73 72
74 if (user != NULL) { 73 if (user != NULL) {
@@ -94,6 +93,8 @@ void webfinger_request(char *qs, int *status, char **actor, char **user)
94 } 93 }
95 } 94 }
96 } 95 }
96
97 return status;
97} 98}
98 99
99 100