Bladeren bron

webfinger_get_handler() returns the status.

default 2 jaren geleden
bovenliggende
commit
11134e58a3
3 gewijzigde bestanden met toevoegingen van 17 en 15 verwijderingen
  1. 1 1
      httpd.c
  2. 2 2
      snac.h
  3. 14 12
      webfinger.c

+ 1 - 1
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) {

+ 2 - 2
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);

+ 14 - 12
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;
 }