Ver código fonte

xs_webmention.h: updated.

grunfink 9 meses atrás
pai
commit
5bf3133f91
2 arquivos alterados com 7 adições e 5 exclusões
  1. 1 1
      xs_version.h
  2. 6 4
      xs_webmention.h

+ 1 - 1
xs_version.h

@@ -1 +1 @@
-/* ad90abcefd455c0ba0faf155dc2976490dbde0b0 2025-08-23T20:36:11+02:00 */
+/* 0a8b987d7bb945fe7844411727d03ac73f417455 2025-10-14T05:21:05+02:00 */

+ 6 - 4
xs_webmention.h

@@ -10,6 +10,8 @@ int xs_webmention_hook(const char *source, const char *target, const char *user_
 
 
 #ifdef XS_IMPLEMENTATION
 #ifdef XS_IMPLEMENTATION
 
 
+#include "xs_http.h"
+
 int xs_webmention_send(const char *source, const char *target, const char *user_agent)
 int xs_webmention_send(const char *source, const char *target, const char *user_agent)
 /* sends a Webmention to target.
 /* sends a Webmention to target.
    Returns: < 0, error; 0, no Webmention endpoint; > 0, Webmention sent */
    Returns: < 0, error; 0, no Webmention endpoint; > 0, Webmention sent */
@@ -29,7 +31,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
     h_req = xs_http_request("HEAD", target, headers, NULL, 0, &status, NULL, &p_size, 0);
     h_req = xs_http_request("HEAD", target, headers, NULL, 0, &status, NULL, &p_size, 0);
 
 
     /* return immediate failures */
     /* return immediate failures */
-    if (status < 200 || status > 299)
+    if (!xs_http_valid_status(status))
         return -1;
         return -1;
 
 
     const char *link = xs_dict_get(h_req, "link");
     const char *link = xs_dict_get(h_req, "link");
@@ -51,7 +53,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
 
 
         g_req = xs_http_request("GET", target, headers, NULL, 0, &status, &payload, &p_size, 0);
         g_req = xs_http_request("GET", target, headers, NULL, 0, &status, &payload, &p_size, 0);
 
 
-        if (status < 200 || status > 299)
+        if (!xs_http_valid_status(status))
             return -1;
             return -1;
 
 
         const char *ctype = xs_dict_get(g_req, "content-type");
         const char *ctype = xs_dict_get(g_req, "content-type");
@@ -107,7 +109,7 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
 
 
         xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0);
         xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0);
 
 
-        if (status < 200 || status > 299)
+        if (!xs_http_valid_status(status))
             status = -4;
             status = -4;
         else
         else
             status = 1;
             status = 1;
@@ -136,7 +138,7 @@ int xs_webmention_hook(const char *source, const char *target, const char *user_
 
 
     g_req = xs_http_request("GET", source, headers, NULL, 0, &status, &payload, &p_size, 0);
     g_req = xs_http_request("GET", source, headers, NULL, 0, &status, &payload, &p_size, 0);
 
 
-    if (status < 200 || status > 299)
+    if (!xs_http_valid_status(status))
         return -1;
         return -1;
 
 
     if (!xs_is_string(payload))
     if (!xs_is_string(payload))